/**
  * transforms the fields to a array for update
  * @return array of fields
  */
 public function getFieldsArray()
 {
     $new_fields = array();
     foreach ($this->fields as $key => $value) {
         $new_fields[$key] = $value;
         if (is_string($value)) {
             $t = strtotime($value);
             if ($t != false) {
                 $new_fields[$key] = Field::getFormatDate($t);
             }
         }
     }
     return $new_fields;
 }
Example #2
0
 /**
  * execute when an item is deleted from an order
  * @param mixed $params
  */
 public function hookActionProductCancel($params)
 {
     if ($params == null) {
         return;
     }
     $event_settings = $this->getEventSettings();
     $target = null;
     if (isset($event_settings['actionProductCancel']) && isset($event_settings['actionProductCancel']['champs'])) {
         $target = new Target();
         $target->values = array();
         if ($this->checkInEventSettings($event_settings, 'actionProductCancel', 'modifDate')) {
             $target->values[$event_settings['actionProductCancel']['champs']['modifDate']] = Field::getFormatDate(time());
         }
     }
     if ($this->context->customer->isLogged()) {
         $this->eventHookSegmentChange($this->context->customer, 'actionProductCancel', $target);
     }
 }
 /**
  * update a Segment
  *
  * @param Segment $segment
  * @return Segment
  */
 public function updateSegment(Segment $segment)
 {
     // convert the object to the array that will transform into json
     $content = array('type' => $segment->type, 'id' => $segment->id, 'name' => $segment->name, 'description' => $segment->description, 'creation' => Field::getFormatDate(strtotime($segment->creation_date)), 'expiration' => Field::getFormatDate(strtotime($segment->expiration_date)), 'isTest' => $segment->for_test);
     list($this->last_result, $this->last_error) = $this->rest_client->put($this->path . '/' . $segment->id, $content);
     $this->erreur = $this->getError($this->last_result, $this->last_error);
     if (isset($this->erreur)) {
         return null;
     }
     if (!Segment::isJsonValid($this->last_result)) {
         $this->erreur = $this->jsonErrorMessage();
         return null;
     }
     return new Segment($this->last_result);
 }