当前位置: 首页>>代码示例>>PHP>>正文


PHP DataObjectCollection::joinArray方法代码示例

本文整理汇总了PHP中DataObjectCollection::joinArray方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectCollection::joinArray方法的具体用法?PHP DataObjectCollection::joinArray怎么用?PHP DataObjectCollection::joinArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataObjectCollection的用法示例。


在下文中一共展示了DataObjectCollection::joinArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save()
 {
     $flash = Flash::Instance();
     if (strtolower($this->_data['saveform']) == 'cancel') {
         $flash->addMessage('Action cancelled');
         sendTo($this->name, 'index', $this->_modules);
     }
     $errors = array();
     $db = DB::Instance();
     $db->StartTrans();
     $header_data = $this->_data['WHTransfer'];
     $lines_data = array();
     if (isset($this->_data['WHTransferLine'])) {
         $lines_data = $this->_data['WHTransferLine'];
         $lines_data = DataObjectCollection::joinArray($lines_data);
     } else {
         $errors[] = 'No Transfer Lines entered';
     }
     if (isset($header_data['id']) && $header_data['id'] != '') {
         $action = 'updated';
         // delete any lines not submitted
         $update = array();
         foreach ($lines_data as $line) {
             $update[$line['id']] = $line['id'];
         }
         $whtransfer = new WHTransfer();
         $whtransfer->load($header_data['id']);
         if ($whtransfer) {
             foreach ($whtransfer->transfer_lines as $line) {
                 if (!isset($update[$line->id])) {
                     $whtransferline = new WHTransferline();
                     $whtransferline->delete($line->id);
                 }
             }
         }
     } else {
         $action = 'added';
     }
     $whtransfer = WHTransfer::Factory($header_data, $lines_data, $errors);
     if ($whtransfer && count($errors) == 0) {
         $whtransfer->save($errors);
     }
     if (count($errors) == 0 && $db->CompleteTrans()) {
         $flash->addMessage('Transfer Number ' . $whtransfer->transfer_number . ' ' . $action . ' successfully');
         sendTo($this->name, 'index', $this->_modules);
     } else {
         $db->FailTrans();
         $flash->addErrors($errors);
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:52,代码来源:WhtransfersController.php

示例2: save_model

 public function save_model($data)
 {
     // Used to save Invoice Header and Invoice Lines from import or copy of existing
     $flash = Flash::Instance();
     if (empty($data['PInvoice']) || empty($data['PInvoiceLine'])) {
         $flash->addError('Error trying to save invoice');
         return false;
     }
     $errors = array();
     $db = DB::Instance();
     $db->StartTrans();
     $header = $data['PInvoice'];
     $lines_data = DataObjectCollection::joinArray($data['PInvoiceLine'], 0);
     if (!$lines_data || empty($lines_data)) {
         $lines_data[] = $data['PInvoiceLine'];
     }
     $invoice = PInvoice::Factory($header, $errors);
     if (!$invoice || count($errors) > 0) {
         $errors[] = 'Invoice validation failed';
     } elseif (!$invoice->save()) {
         $errors[] = 'Invoice creation failed';
     }
     if ($invoice) {
         foreach ($lines_data as $line) {
             $line['invoice_id'] = $invoice->{$invoice->idField};
             $invoiceline = PInvoiceLine::Factory($invoice, $line, $errors);
             if (!$invoiceline || count($errors) > 0) {
                 $errors[] = 'Invoice Line validation failed for line ' . $line['line_number'];
             } elseif (!$invoiceline->save()) {
                 $errors[] = 'Invoice Line creation failed for line ' . $line['line_number'];
             }
         }
     }
     if (count($errors) === 0) {
         if (!$invoice->save()) {
             $errors[] = 'Error updating Invoice totals';
         } else {
             $result = array('internal_id' => $invoice->{$invoice->idField}, 'internal_identifier_field' => $invoice->identifierField, 'internal_identifier_value' => $invoice->getidentifierValue());
         }
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
         $db->FailTrans();
         $result = false;
     }
     $db->CompleteTrans();
     return $result;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:48,代码来源:PInvoice.php

示例3: save

 public function save()
 {
     /**
      * to ensure the redirect htis the right page, we must check the 
      * original action if it is day, week or month view we can construct 
      * a sentTo, if it is anything else we must fire a sendBack
      */
     switch ($this->_data['original_action']) {
         case "dayview":
         case "weekview":
         case "monthview":
             $original_action = $this->_data['original_action'];
             break;
         default:
             $original_action = FALSE;
     }
     $flash = Flash::Instance();
     $calendar = new Calendar();
     if (!isset($this->_data['CalendarEvent']['calendar_id']) || $this->_data['CalendarEvent']['calendar_id'] == '') {
         $flash->addError("You must specify a calendar");
         if ($original_action != FALSE) {
             sendTo('index', $original_action, 'calendar');
         } else {
             sendBack();
         }
     }
     if (!array_key_exists($this->_data['CalendarEvent']['calendar_id'], $calendar->getWritableCalendars())) {
         $flash->addError("You haven't got permission to write to this calendar");
         if ($original_action != FALSE) {
             sendTo('index', $original_action, 'calendar');
         } else {
             sendBack();
         }
     }
     if (isset($this->_data['CalendarEventAttendee'])) {
         $attendees = DataObjectCollection::joinArray($this->_data['CalendarEventAttendee'], 1);
         foreach ($attendees as $key => $attendee) {
             foreach ($attendees as $s_key => $s_attendee) {
                 if ($attendee['person_id'] == $s_attendee['person_id'] && $key != $s_key) {
                     $this->_new();
                     $this->_templateName = $this->getTemplateName('new');
                     $flash->addError('Please ensure to only add any attendee once');
                     return;
                 }
             }
         }
     }
     if (!isset($this->_data['book'])) {
         if ($this->_data['CalendarEvent']['start_time'] != $this->_data['CalendarEvent']['end_time']) {
             $this->_data['CalendarEvent']['all_day'] = true;
         }
         if (isset($this->_data['CalendarEvent']['start_time'])) {
             $this->_data['CalendarEvent']['start_time'] .= !empty($this->_data['CalendarEvent']['start_time_hours']) ? ' ' . $this->_data['CalendarEvent']['start_time_hours'] : ' 00';
             $this->_data['CalendarEvent']['start_time'] .= ':';
             $this->_data['CalendarEvent']['start_time'] .= !empty($this->_data['CalendarEvent']['start_time_minutes']) ? $this->_data['CalendarEvent']['start_time_minutes'] : '00';
         }
         if (isset($this->_data['CalendarEvent']['end_time'])) {
             $this->_data['CalendarEvent']['end_time'] .= !empty($this->_data['CalendarEvent']['end_time_hours']) ? ' ' . $this->_data['CalendarEvent']['end_time_hours'] : ' 00';
             $this->_data['CalendarEvent']['end_time'] .= ':';
             $this->_data['CalendarEvent']['end_time'] .= !empty($this->_data['CalendarEvent']['end_time_minutes']) ? $this->_data['CalendarEvent']['end_time_minutes'] : '00';
         }
         $temp_start_time = $this->_data['CalendarEvent']['start_time_hours'] . ":" . $this->_data['CalendarEvent']['start_time_minutes'];
         $temp_end_time = $this->_data['CalendarEvent']['end_time_hours'] . ":" . $this->_data['CalendarEvent']['end_time_minutes'];
         if ($temp_start_time == '00:00' || $temp_start_time == ':' || $temp_end_time == '00:00' || $temp_end_time == ':') {
             $this->_data['CalendarEvent']['all_day'] = true;
         }
         if ($this->check_collisions($this->_data['CalendarEvent']['start_time'], $this->_data['CalendarEvent']['end_time']) !== false) {
             $this->confirm_collision();
             $this->_templateName = $this->getTemplateName('confirm_collision');
             return;
         }
     } elseif (isset($this_data['dont_book'])) {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
         return;
     }
     if (parent::save('CalendarEvent')) {
         if (isset($this->_data['CalendarEventAttendee'])) {
             foreach ($attendees as $attendee) {
                 $attendee['calendar_event_id'] = $this->_data['id'];
                 $model = call_user_func(array('CalendarEventAttendee', "Factory"), $attendee, array(), 'CalendarEventAttendee');
                 if (is_a($model, 'CalendarEventAttendee')) {
                     $model->save();
                 }
             }
         }
         if ($original_action != FALSE) {
             sendTo('index', $original_action, 'calendar');
         } else {
             sendBack();
         }
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:96,代码来源:CalendareventsController.php


注:本文中的DataObjectCollection::joinArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。