コード例 #1
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->setPropertiesDefine(array('sample_no' => array('getter' => function (SampleProduceOrderMapSamples $item) {
         if (!$item->sample_id) {
             return '';
         }
         return Sample::findOneByPk($item->sample_id)->sample_no;
     }), 'sample' => array('getter' => function (SampleProduceOrderMapSamples $item) {
         if (!$item->sample_id) {
             return '';
         }
         return Sample::findOneByPk($item->sample_id);
     }), 'sample_type_name' => array('getter' => function (SampleProduceOrderMapSamples $item) {
         if (!$item->sample_id) {
             return '';
         }
         return Sample::findOneByPk($item->sample_id)->sample_type_name;
     }), 'produce_type_text' => array('getter' => function (SampleProduceOrderMapSamples $item) {
         $def = self::getPropertiesDefine('produce_type');
         return $def['options'][$item->produce_type];
     }), 'image_list' => array('getter' => function (SampleProduceOrderMapSamples $item) {
         $tmp = SampleImage::find('sample_id=?', $item->sample_id)->all();
         return array_column($tmp, 'image_url');
     }), 'produce_state' => array('getter' => function (self $item) {
         if ($item->produce_employee_id && $item->produce_process_state) {
             $process_n = WorkProcess::findOneByPk($item->produce_process_state)->name;
             $employee_n = Employee::findOneByPk($item->produce_employee_id)->name;
             return "{$process_n}({$employee_n})";
         }
         return '';
     })));
 }
コード例 #2
0
ファイル: SampleProduceOrder.php プロジェクト: sasumi/SvnPQA
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->setPropertiesDefine(array('customer_id' => array('options' => function (SampleProduceOrder $item = null) {
         if ($item && $item->customer_id) {
             $company_alias_name = Customer::findOneByPk($item->customer_id)->company_alias_name;
             return array($item->customer_id => $company_alias_name);
         }
         return null;
     }, 'alias' => '客户'), 'customer' => array('getter' => function (self $item) {
         if ($item) {
             return Customer::findOneByPk($item->customer_id);
         }
         return null;
     }), 'contact' => array('getter' => function (SampleProduceOrder $item) {
         if ($item->contact_id) {
             return CustomerContact::findOneByPk($item->contact_id);
         }
         return null;
     }), 'contact_id' => array('options' => function (SampleProduceOrder $item = null) {
         if ($item && $item->contact_id) {
             $contact_name = CustomerContact::findOneByPk($item->contact_id)->chinese_name;
             return array($item->contact_id => $contact_name);
         }
         return null;
     }, 'alias' => '联系人'), 'boss_head_employee_id' => array('options' => function () {
         $tmp = Employee::find('state=?', Employee::STATE_ENABLED)->all(true);
         return array_combine(array_column($tmp, 'id'), array_column($tmp, 'name'));
     }, 'display' => function (self $item) {
         $tmp = Employee::findOneByPk($item->boss_head_employee_id);
         if (!$tmp) {
             return '';
         }
         return $tmp->state == Employee::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>';
     }, 'alias' => '负责人'), 'produce_finish_date' => array('default' => date('Y-m-d')), 'currency_id' => array('options' => function () {
         $tmp = Currency::find()->all(true);
         return array_combine(array_column($tmp, 'id'), array_column($tmp, 'unit_name'));
     }, 'display' => function (self $item) {
         if ($item) {
             $tmp = Currency::find()->all(true);
             $tmp = array_group($tmp, 'id', true);
             return $tmp[$item->currency_id]['unit_name'];
         }
         return '';
     }), 'product_fee' => array('description' => 'RMB'), 'business_order' => array('getter' => function (self $item) {
         return BusinessOrder::findOneByPk($item->business_order_id);
     })));
 }