PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/sgl/drafts/licencia_edit.php

http://logisticsouth.googlecode.com/
PHP | 148 lines | 79 code | 32 blank | 37 comment | 3 complexity | 1c639e5b75cb72afa2bf5de0339a900b MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. // Load the QCubed Development Framework
  3. require('../qcubed.inc.php');
  4. require(__FORMBASE_CLASSES__ . '/LicenciaEditFormBase.class.php');
  5. /**
  6. * This is a quick-and-dirty draft QForm object to do Create, Edit, and Delete functionality
  7. * of the Licencia class. It uses the code-generated
  8. * LicenciaMetaControl class, which has meta-methods to help with
  9. * easily creating/defining controls to modify the fields of a Licencia columns.
  10. *
  11. * Any display customizations and presentation-tier logic can be implemented
  12. * here by overriding existing or implementing new methods, properties and variables.
  13. *
  14. * NOTE: This file is overwritten on any code regenerations. If you want to make
  15. * permanent changes, it is STRONGLY RECOMMENDED to move both licencia_edit.php AND
  16. * licencia_edit.tpl.php out of this Form Drafts directory.
  17. *
  18. * @package My QCubed Application
  19. * @subpackage Drafts
  20. */
  21. class LicenciaEditForm extends LicenciaEditFormBase {
  22. protected $calCalendarIni;
  23. protected $calCalendarFin;
  24. protected $calCalendarCNP;
  25. // Override Form Event Handlers as Needed
  26. // protected function Form_Run() {}
  27. // protected function Form_Load() {}
  28. // protected function Form_Create() {}
  29. //
  30. //
  31. protected function Form_Create() {
  32. parent::Form_Create();
  33. // Use the CreateFromPathInfo shortcut (this can also be done manually using the LicenciaMetaControl constructor)
  34. // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
  35. $this->mctLicencia = LicenciaMetaControl::CreateFromPathInfo($this);
  36. // Call MetaControl's methods to create qcontrols based on Licencia's data fields
  37. $this->lblIdLICENCIA = $this->mctLicencia->lblIdLICENCIA_Create();
  38. $this->lstEMPRESAIdEMPRESAObject = $this->mctLicencia->lstEMPRESAIdEMPRESAObject_Create();
  39. $this->lstPROVEEDORIdPROVEEDORObject = $this->mctLicencia->lstPROVEEDORIdPROVEEDORObject_Create();
  40. $this->calFechaInicio = $this->mctLicencia->calFechaInicio_Create();
  41. $this->calFechaFin = $this->mctLicencia->calFechaFin_Create();
  42. $this->calFechaFinEstimada = $this->mctLicencia->calFechaFinEstimada_Create();
  43. $this->txtNumeroProforma = $this->mctLicencia->txtNumeroProforma_Create();
  44. $this->txtNumeroCNP = $this->mctLicencia->txtNumeroCNP_Create();
  45. $this->calVencimientoCNP = $this->mctLicencia->calVencimientoCNP_Create();
  46. $this->txtStatus = $this->mctLicencia->txtStatus_Create();
  47. $this->txtFormaPago = $this->mctLicencia->txtFormaPago_Create();
  48. $this->txtTipo = $this->mctLicencia->txtTipo_Create();
  49. $this->txtFlete = $this->mctLicencia->txtFlete_Create();
  50. $this->txtSeguro = $this->mctLicencia->txtSeguro_Create();
  51. $this->lstPROCESOIdPROCESOObject = $this->mctLicencia->lstPROCESOIdPROCESOObject_Create();
  52. $this->calCalendarIni = new QCalendar($this, $this->calFechaInicio); //Inicializo el QCalendar
  53. $this->calFechaInicio->AddAction(new QFocusEvent(), new QBlurControlAction($this->calFechaInicio)); //Creo el evento cuando haga clic sobre calCotFecha
  54. $this->calFechaInicio->AddAction(new QClickEvent(), new QShowCalendarAction($this->calCalendarIni));
  55. $this->calFechaInicio->AddAction(new QChangeEvent(), new QAjaxAction('Date_Change'));
  56. $this->calCalendarFin = new QCalendar($this, $this->calFechaFin); //Inicializo el QCalendar
  57. $this->calFechaFin->AddAction(new QFocusEvent(), new QBlurControlAction($this->calFechaFin)); //Creo el evento cuando haga clic sobre calCotFecha
  58. $this->calFechaFin->AddAction(new QClickEvent(), new QShowCalendarAction($this->calCalendarFin));
  59. $this->calCalendarCNP = new QCalendar($this, $this->calVencimientoCNP); //Inicializo el QCalendar
  60. $this->calVencimientoCNP->AddAction(new QFocusEvent(), new QBlurControlAction($this->calVencimientoCNP)); //Creo el evento cuando haga clic sobre calCotFecha
  61. $this->calVencimientoCNP->AddAction(new QClickEvent(), new QShowCalendarAction($this->calCalendarCNP));
  62. // Create Buttons and Actions on this Form
  63. $this->btnSave = new QButton($this);
  64. $this->btnSave->Text = QApplication::Translate('Save');
  65. $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
  66. $this->btnSave->CausesValidation = true;
  67. $this->btnCancel = new QButton($this);
  68. $this->btnCancel->Text = QApplication::Translate('Cancel');
  69. $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
  70. $this->btnDelete = new QButton($this);
  71. $this->btnDelete->Text = QApplication::Translate('Delete');
  72. $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('Licencia') . '?'));
  73. $this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click'));
  74. $this->btnDelete->Visible = $this->mctLicencia->EditMode;
  75. }
  76. protected function Date_Change() {
  77. // Whenever the user changes the selected listbox item, let's
  78. // update the label to reflect the selected item
  79. $date = $this->calFechaInicio->DateTime;
  80. //$newdate = strtotime ( '+180 day' , strtotime ( $date ) ) ;
  81. if ($this->lstPROCESOIdPROCESOObject) {
  82. $Proceso = Proceso::LoadByIdPROCESO((int)$this->lstPROCESOIdPROCESOObject->Text);
  83. $newdate = date( 'j M Y' , strtotime ( '+'.$Proceso->Duracion.' day' ,strtotime($date)));
  84. $this->calFechaFin->Text= $newdate;
  85. $this->calVencimientoCNP->Text= $newdate;
  86. }
  87. }
  88. protected function Form_Validate() {
  89. // By default, we report that Custom Validations passed
  90. if ($this->calFechaInicio->DateTime > $this->calFechaFin->DateTime) {
  91. $this->calFechaFin->Warning = "La fecha debe ser inferior a la de inicio";
  92. return false;
  93. }
  94. $blnToReturn = true;
  95. // Custom Validation Rules
  96. // TODO: Be sure to set $blnToReturn to false if any custom validation fails!
  97. $blnFocused = false;
  98. foreach ($this->GetErrorControls() as $objControl) {
  99. // Set Focus to the top-most invalid control
  100. if (!$blnFocused) {
  101. $objControl->Focus();
  102. $blnFocused = true;
  103. }
  104. // Blink on ALL invalid controls
  105. $objControl->Blink();
  106. }
  107. return $blnToReturn;
  108. }
  109. protected function RedirectToListPage() {
  110. QApplication::Redirect(__VIRTUAL_DIRECTORY__ . __FORM_ADMINISTRADOR__ . '/licencia_list.php');
  111. }
  112. }
  113. // Go ahead and run this form object to render the page and its event handlers, implicitly using
  114. // licencia_edit.tpl.php as the included HTML template file
  115. LicenciaEditForm::Run('LicenciaEditForm');
  116. ?>