Exemple #1
0
 function exportAction()
 {
     // make sure we have a valid ID
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     $connectionModel = new Fulfillment();
     $connectionModel->findByPk($id);
     $model0 = new FulfillmentField();
     $model1 = new FulfillmentFields('FulfillmentField');
     $model2 = new Order();
     $model3 = new Payment();
     $model4 = new Click();
     // grab fields assigned to fulfillment_id
     $assignedFields = $model1->getFulfillmentFieldsByFulfillmentId($id);
     $assignColumns = array();
     $assignedOColumns = array();
     $assignedPColumns = array();
     $assignedCColumns = array();
     foreach ($assignedFields as $af) {
         $assignColumns[] = $af['fulfillment_field_column'];
         if ($af['fulfillment_field_model'] == 'order') {
             $assignedOColumns[] = $af['fulfillment_field_column'];
         } else {
             if ($af['fulfillment_field_model'] == 'payment') {
                 $assignedPColumns[] = $af['fulfillment_field_column'];
             } else {
                 if ($af['fulfillment_field_model'] == 'click') {
                     $assignedCColumns[] = $af['fulfillment_field_column'];
                 }
             }
         }
     }
     // build fieldsArray to be used in the "default" export columns selection.  don't include fields that are already assigned
     $fields = $model1->getFulfillmentFieldsByFulfillmentId(0);
     $fieldsArray = array();
     $parentsArray = array();
     foreach ($fields as $field) {
         if ($field['fulfillment_field_model'] == 'parent') {
             $parentsArray[] = array("fulfillment_field_column" => $field['fulfillment_field_column'], "fulfillment_field_name" => $field['fulfillment_field_name'], "fulfillment_field_model" => $field['fulfillment_field_model'], "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => '');
         } else {
             if (!in_array($field['fulfillment_field_column'], $assignColumns)) {
                 $fieldsArray[] = array("fulfillment_field_column" => $field['fulfillment_field_column'], "fulfillment_field_name" => $field['fulfillment_field_name'], "fulfillment_field_model" => $field['fulfillment_field_model'], "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => '');
             }
         }
         // , "rank"=>$idex++
     }
     // build orderFieldsArray to be used in the "additional order" export columns selection.  don't include fields that are already assigned
     $oFields = $model2->attributeLabels();
     $oKeys = array_keys($oFields);
     $oFieldsArray = array();
     foreach ($oKeys as $field) {
         if (!in_array($field, $assignedOColumns)) {
             $oFieldsArray[] = array("fulfillment_field_column" => $field, "fulfillment_field_name" => $oFields[$field], "fulfillment_field_model" => 'order', "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => '');
         }
         // , "rank"=>$idex++
     }
     // build paymentFieldsArray to be used in the "additional payment" export columns selection.  don't include fields that are already assigned
     $pFields = $model3->attributeLabels();
     $pKeys = array_keys($pFields);
     $pFieldsArray = array();
     foreach ($pKeys as $field) {
         if (!in_array($field, $assignedPColumns)) {
             $pFieldsArray[] = array("fulfillment_field_column" => $field, "fulfillment_field_name" => $pFields[$field], "fulfillment_field_model" => 'payment', "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => '');
         }
         // , "rank"=>$idex++
     }
     // build cFieldsArray to be used in the "additional click" export columns selection.  don't include fields that are already assigned
     $cFields = $model4->attributeLabels();
     $cKeys = array_keys($cFields);
     $cFieldsArray = array();
     foreach ($cKeys as $field) {
         if (!in_array($field, $assignedCColumns)) {
             $cFieldsArray[] = array("fulfillment_field_column" => $field, "fulfillment_field_name" => $cFields[$field], "fulfillment_field_model" => 'click', "checked" => false, "fulfillment_field_rank" => '', "fulfillment_field_static" => '');
         }
         // , "rank"=>$idex++
     }
     // preload the JQX assets
     Assets::css('jqwidgets/jqx.base');
     Assets::js('jqwidgets/jqxcore');
     Assets::js('jqwidgets/jqxdata');
     Assets::js('jqwidgets/jqxbuttons');
     Assets::js('jqwidgets/jqxscrollbar');
     Assets::js('jqwidgets/jqxmenu');
     Assets::js('jqwidgets/jqxcheckbox');
     Assets::js('jqwidgets/jqxlistbox');
     Assets::js('jqwidgets/jqxdropdownlist');
     Assets::js('jqwidgets/jqxgrid');
     Assets::js('jqwidgets/jqxgrid.edit');
     Assets::js('jqwidgets/jqxgrid.selection');
     Assets::js('jqwidgets/jqxdata.export');
     Assets::js('jqwidgets/jqxgrid.export');
     Assets::js('jqwidgets/jqxgrid.columnsresize');
     Assets::js('jqwidgets/jqxdropdownbutton');
     $this->render('export', array('model' => $model0, 'connectionModel' => $connectionModel, 'defaultFields' => $fieldsArray, 'assignedFields' => $assignedFields, 'orderFields' => $oFieldsArray, 'paymentCCFields' => $pFieldsArray, 'clickFields' => $cFieldsArray, 'parentFields' => $parentsArray));
 }
Exemple #2
0
 public function cloneModel($ids = null)
 {
     $this->alias = 'copy_' . $this->alias;
     $this->server = long2ip($this->server);
     // M.Scully - create custom clone function to handle fulfillment field cloning
     //return parent::cloneModel($ids);
     if ($this->beforeClone()) {
         $db = self::$_msql;
         $pk = $this->getPrimaryField();
         $tableName = $this->tableName();
         // grab pk to use with Fulfillment Field cloning
         $pkValue = $this->{$pk};
         if (!$tableName || !$pk) {
             return FALSE;
         }
         unset($this->{$pk});
         $this->setIsNewRecord(TRUE);
         if (!$this->save()) {
             return false;
         }
         // grab fulfillment fields, then copy
         $mFF = new FulfillmentField();
         $mFFs = new FulfillmentFields('FulfillmentField');
         $fields = $mFFs->getFulfillmentFieldsByFulfillmentId($pkValue);
         foreach ($fields as $field) {
             $field['fulfillment_id'] = $this->getPkValue();
             $mFF->fillFromArray($field);
             $mFF->setIsNewRecord(TRUE);
             $mFF->save();
         }
         return true;
     }
     return false;
 }
Exemple #3
0
 public function getPackageCustom($fulfillment, $header = false)
 {
     // grab assign custom fulfillment fields
     $f = new FulfillmentFields('FulfillmentField');
     $assignedFields = $f->getFulfillmentFieldsByFulfillmentId($fulfillment->fulfillment_id);
     // check for dateformat value
     if ($fulfillment->fulfillment_date_format) {
         $this->dateFormat = $fulfillment->fulfillment_date_format;
     }
     $rtrArray = array();
     $arrDets = array();
     // grab custom column list headers
     foreach ($assignedFields as $af) {
         $headers[] = $af['fulfillment_field_name'];
     }
     reset($assignedFields);
     // grab default column values
     $tempArray = $this->getRow();
     if ($header) {
         $rtrArray[] = array_values($headers);
     }
     foreach ($assignedFields as $index => $af) {
         $aV = '';
         if ($af['fulfillment_field_model']) {
             // check for specified values not in default getOrderRow array
             // what model is it?
             // first, check to see if we need to grab info from the parent order (assuming this is an attached order)
             if ($af['fulfillment_field_model'] == 'parent') {
                 $aV = $this->getParentValue($af['fulfillment_field_column']);
             } elseif ($af['fulfillment_field_model'] == 'payment') {
                 $n = $this->payment->note1;
                 $n1 = unserialize(NoteBase64::decode($n));
                 $aV = $n1[$af['fulfillment_field_column']];
             } elseif ($af['fulfillment_field_model'] == 'order') {
                 $aV = $this->orders[$this->main_order_id]->{$af}['fulfillment_field_column'];
             } elseif ($af['fulfillment_field_model'] == 'static') {
                 // this allows for the entry of static info into the column
                 $aV = $af['fulfillment_field_static'];
             }
             /* Add additional model types (other payments, shipping, gateway, etc..) 
             				elseif ($af['fulfillment_field_model'] == '') {
             				$aV = $item-> MODEL NAME ->$c;
             			} */
         } else {
             $aV = empty($tempArray[$af['fulfillment_field_column']]) ? '' : $tempArray[$af['fulfillment_field_column']];
         }
         $arrDets[] = utf8_decode($aV);
     }
     $rtrArray[] = array_values($arrDets);
     return $rtrArray;
 }