Index: branches/5.2.x/units/orders/orders_event_handler.php =================================================================== diff -u -N -r15047 -r15061 --- branches/5.2.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 15047) +++ branches/5.2.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ setRedirectParams(Array('opener' => 's'), true); + $event->SetRedirectParam('opener', 's'); } if ($event->status == kEvent::erSUCCESS) { @@ -1598,7 +1600,7 @@ * @return void * @access protected */ - protected function OnPreCreate(&$event) + protected function OnPreCreate(kEvent &$event) { parent::OnPreCreate($event); @@ -1620,13 +1622,14 @@ * @return void * @access protected */ - protected function OnBeforeClone(&$event) + protected function OnBeforeClone(kEvent &$event) { parent::OnBeforeClone($event); $object =& $event->getObject(); + /* @var $object OrdersItem */ - if (substr($event->Special, 0, 9) == 'recurring') { + if ( substr($event->Special, 0, 9) == 'recurring' ) { $object->SetDBField('SubNumber', $object->getNextSubNumber()); $object->SetDBField('OriginalAmount', 0); // needed in this case ? } @@ -1710,7 +1713,7 @@ function OnOrderPrint(&$event) { - $event->setRedirectParams(Array('opener'=>'s'), true); + $event->SetRedirectParam('opener', 's'); } /** @@ -2288,15 +2291,21 @@ * Set's status incomplete to all cloned orders * * @param kEvent $event + * @return void + * @access protected */ - function OnAfterClone(&$event) + protected function OnAfterClone(kEvent &$event) { + parent::OnAfterClone($event); + $id = $event->getEventParam('id'); - $table = $this->Application->getUnitOption($event->Prefix,'TableName'); - $id_field = $this->Application->getUnitOption($event->Prefix,'IDField'); + $table = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); // set cloned order status to Incomplete - $sql = 'UPDATE '.$table.' SET Status = 0 WHERE '.$id_field.' = '.$id; + $sql = 'UPDATE ' . $table . ' + SET Status = 0 + WHERE ' . $id_field . ' = ' . $id; $this->Conn->Query($sql); } @@ -2310,7 +2319,7 @@ * @return void * @access protected */ - protected function OnAfterItemLoad(&$event) + protected function OnAfterItemLoad(kEvent &$event) { parent::OnAfterItemLoad($event); @@ -2358,7 +2367,7 @@ * @return void * @access protected */ - protected function OnBeforeItemCreate(&$event) + protected function OnBeforeItemCreate(kEvent &$event) { parent::OnBeforeItemCreate($event); @@ -2376,7 +2385,7 @@ * @return void * @access protected */ - protected function OnBeforeItemUpdate(&$event) + protected function OnBeforeItemUpdate(kEvent &$event) { parent::OnBeforeItemUpdate($event); @@ -3688,23 +3697,30 @@ * Allows configuring export options * * @param kEvent $event + * @return void + * @access protected */ - function OnBeforeExportBegin(&$event) + protected function OnBeforeExportBegin(kEvent &$event) { - $options = $event->getEventParam('options') ; + parent::OnBeforeExportBegin($event); - $items_list =& $this->Application->recallObject($event->Prefix.'.'.$this->Application->RecallVar('export_oroginal_special'), $event->Prefix.'_List'); + $options = $event->getEventParam('options'); + + $items_list =& $this->Application->recallObject($event->Prefix . '.' . $this->Application->RecallVar('export_oroginal_special'), $event->Prefix . '_List'); + /* @var $items_list kDBList */ + $items_list->SetPerPage(-1); - if ($options['export_ids'] != '') { - $items_list->AddFilter('export_ids', $items_list->TableName.'.'.$items_list->IDField.' IN ('.implode(',',$options['export_ids']).')'); + + if ( $options['export_ids'] != '' ) { + $items_list->AddFilter('export_ids', $items_list->TableName . '.' . $items_list->IDField . ' IN (' . implode(',', $options['export_ids']) . ')'); } - $options['ForceCountSQL'] = $items_list->getCountSQL( $items_list->GetSelectSQL(true,false) ); + $options['ForceCountSQL'] = $items_list->getCountSQL($items_list->GetSelectSQL(true, false)); $options['ForceSelectSQL'] = $items_list->GetSelectSQL(); - $event->setEventParam('options',$options); + $event->setEventParam('options', $options); - $object =& $this->Application->recallObject($event->Prefix.'.export'); + $object =& $this->Application->recallObject($event->Prefix . '.export'); /* @var $object kDBItem */ $object->SetField('Number', 999999); @@ -3716,18 +3732,20 @@ * * @param kEvent $event * @return Array + * @access protected */ - function getCustomExportColumns(&$event) + public function getCustomExportColumns(kEvent &$event) { $columns = parent::getCustomExportColumns($event); - $new_columns = Array( + + $new_columns = Array ( '__VIRTUAL__CustomerName' => 'CustomerName', '__VIRTUAL__TotalAmount' => 'TotalAmount', '__VIRTUAL__AmountWithoutVAT' => 'AmountWithoutVAT', '__VIRTUAL__SubtotalWithDiscount' => 'SubtotalWithDiscount', '__VIRTUAL__SubtotalWithoutDiscount' => 'SubtotalWithoutDiscount', '__VIRTUAL__OrderNumber' => 'OrderNumber', - ); + ); return array_merge($columns, $new_columns); } @@ -3740,7 +3758,7 @@ * @return void * @access protected */ - protected function OnSave(&$event) + protected function OnSave(kEvent &$event) { parent::OnSave($event); @@ -3759,18 +3777,22 @@ } /** - * Occures before an item is copied to live table (after all foreign keys have been updated) + * Occurs before an item is copied to live table (after all foreign keys have been updated) * Id of item being copied is passed as event' 'id' param * * @param kEvent $event + * @return void + * @access protected */ - function OnBeforeCopyToLive(&$event) + protected function OnBeforeCopyToLive(kEvent &$event) { + parent::OnBeforeCopyToLive($event); + $id = $event->getEventParam('id'); - $copied_ids = unserialize($this->Application->RecallVar($event->Prefix.'_copied_ids'.$this->Application->GetVar('wid'), serialize(array()))); + $copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(array ()))); array_push($copied_ids, $id); - $this->Application->StoreVar($event->Prefix.'_copied_ids'.$this->Application->GetVar('wid'), serialize($copied_ids) ); + $this->Application->StoreVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize($copied_ids)); } /**