Array('subitem' => 'add|edit'), ); $this->permMapping = array_merge($this->permMapping, $permissions); } /** * Adds products from selected categories and their sub-categories and directly selected products to coupon items with duplicate checking * * @param kEvent $event */ function OnProcessSelected(&$event) { // uses another handler event, because does the same stuff but on different table $di_handler =& $this->Application->recallObject('di_EventHandler'); $di_handler->OnProcessSelected($event); } /** * Allows to set discount on entire order * * @param kEvent $event * @todo get parent item id through $object->getLinkedInfo()['ParentId'] * @access public */ function OnEntireOrder(&$event) { $object =& $event->GetObject(); $sql = 'DELETE FROM '.$object->TableName.' WHERE CouponId='.$this->Application->GetVar('coup_id'); $this->Conn->Query($sql); $object->SetDBField('CouponId', $this->Application->GetVar('coup_id')); $object->SetDBField('ItemResourceId', -1); $object->SetDBField('ItemType', 0); if( $object->Create() ) { if( $object->IsTempTable() ) $object->setTempID(); $this->customProcessing($event, 'after'); $event->status=erSUCCESS; $event->redirect_params = Array('opener' => 's'); //stay! } else { $event->status=erFAIL; $this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate'); $object->setID(0); } } /** * Deletes discount items where hooked item (product) is used * * @param kEvent $event */ function OnDeleteCouponItem(&$event) { $main_object =& $event->MasterEvent->getObject(); $resource_id = $main_object->GetDBField('ResourceId'); $table = $this->Application->getUnitOption($event->Prefix,'TableName'); $sql = 'DELETE FROM '.$table.' WHERE ItemResourceId = '.$resource_id; $this->Conn->Query($sql); } }