Esempio n. 1
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->setPropertiesDefine(array('sample_no' => array('getter' => function (BusinessOrderSamples $item) {
         $tmp = Sample::findOneByPk($item->sample_id);
         return $tmp ? $tmp->sample_no : '已删除';
     }, 'alias' => '货号'), 'sample_first_image_src' => array('getter' => function (BusinessOrderSamples $item) {
         $p = SampleImage::find('sample_id=?', $item->sample_id)->one();
         if ($p) {
             return $p->image_url;
         }
         return '';
     }, 'rel' => 'upload-image', 'alias' => '样张'), 'outer_box_size' => array('getter' => function (BusinessOrderSamples $item) {
         $p = SamplePackage::findOneByPk($item->sample_package_id);
         return ($p->outer_box_length ?: 0) . ' x ' . ($p->outer_box_width ?: 0) . ' x ' . ($p->outer_box_height ?: 0);
     }, 'alias' => '外箱尺寸'), 'pack_name' => array('getter' => function (BusinessOrderSamples $item) {
         $p = SamplePackage::findOneByPk($item->sample_package_id);
         return $p->pack_name;
     }, 'alias' => '包装方式'), 'sample_sum' => array('getter' => function (self $item) {
         return $item->sample_num * $item->sample_unit_price;
     }, 'alias' => '小计'), 'pack_desc' => array('getter' => function (BusinessOrderSamples $item) {
         $p = SamplePackage::findOneByPk($item->sample_package_id);
         return $p->pack_desc;
     }, 'alias' => '包装描述')));
 }
 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 '';
     })));
 }
Esempio n. 3
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->setPropertiesDefine(array('sample_type_name' => array('getter' => function (Sample $item) {
         return GlobalConf::$sample_type_desc_map[$item->sample_type];
     }), 'sample_list' => array('getter' => function (Sample $item) {
         if ($item->sample_type != GlobalConf::SAMPLE_TYPE_SUITE) {
             throw new \Exception('样品不属于套件');
         }
         $tmp = SuiteSampleMapSingleSample::find('suite_sample_id=?', $item->id)->all(true);
         $sample_id_list = array_column($tmp, 'single_sample_id');
         return Sample::findByPks($sample_id_list);
     }), 'material_id' => array('options' => function () {
         $tmp = SampleMaterial::find('state=?', SampleMaterial::STATE_ENABLED)->all(true);
         return array_combine(array_column($tmp, 'id'), array_column($tmp, 'name'));
     }, 'display' => function (self $item = null) {
         $tmp = SampleMaterial::findOneByPk($item->material_id);
         if (!$tmp) {
             return '';
         }
         return $tmp->state == SampleMaterial::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>';
     }), 'category_id' => array('options' => function () {
         $tmp = SampleCategory::find('state=?', SampleCategory::STATE_ENABLED)->all(true);
         $tmp = array_filter_subtree(0, $tmp);
         foreach ($tmp as $k => $item) {
             $tmp[$k]['name'] = str_repeat('&nbsp;', $item['tree_level'] * 5) . '|-' . $item['name'];
         }
         return array_combine(array_column($tmp, 'id'), array_column($tmp, 'name'));
     }, 'display' => function (self $item = null) {
         if ($item->category_id) {
             $tmp = SampleCategory::findOneByPk($item->category_id);
             if (!$tmp) {
                 return '';
             }
             return $tmp->state == SampleCategory::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>';
         }
         return '';
     }), 'extend_info' => array('getter' => function (Sample $item) {
         if ($item->sample_type != GlobalConf::SAMPLE_TYPE_SINGLE) {
             throw new \Exception('样品不属于单品');
         }
         return SingleSample::find('sample_id=?', $item->id)->one() ?: new SingleSample(array('sample_id' => $item->id));
     }), 'produce_data' => array('getter' => function (Sample $item) {
         if ($item && $item->sample_type == GlobalConf::SAMPLE_TYPE_SINGLE) {
             return SampleProduceData::find('sample_id=?', $item->id)->one();
         }
         return null;
     }), 'first_image_src' => array('getter' => function (Sample $item) {
         return SampleImage::find('sample_id=?', $item->id)->ceil('image_url');
     }, 'rel' => 'upload-image'), 'key_words' => array('rel' => 'keywords'), 'tags' => array('rel' => 'tags'), 'package_list' => array('getter' => function (Sample $item) {
         return SamplePackage::find('sample_id = ?', $item->id)->all();
     })));
 }
Esempio n. 4
0
 /**
  * @param $get
  * @param $post
  * @return array
  */
 public function update($get, $post)
 {
     $sample_id = $get['sample_id'] ?: $post['sample_id'];
     $sample_info = Sample::findOneByPk($sample_id);
     if ($post) {
         SampleWorkCost::deleteWhere(0, 'sample_id = ?', $sample_id);
         $data = array();
         foreach ($post['price_list'] as $flow_id => $price) {
             $data[] = array('sample_id' => $sample_id, 'technic_flow_id' => $flow_id, 'price' => $price);
         }
         SampleWorkCost::insertMany($data);
         return new Result('操作成功', true);
     }
     $technic_flow_list = (new SingleSample())->getPropertiesDefine('technic_flow_id_list')['options'];
     $tmp = SampleWorkCost::find('sample_id = ?', $sample_id)->all(true);
     $cost_data = array_group($tmp, 'technic_flow_id', true);
     return array('sample_info' => $sample_info, 'technic_flow_list' => $technic_flow_list, 'cost_data' => $cost_data);
 }
Esempio n. 5
0
				</td>
			</tr>
			<tr>
				<td>样品图片</td>
				<td>
					<?php 
echo \www\ViewBase::displayField('sample_first_image_src', $sample);
?>
				</td>
			</tr>
			<tr>
				<td class="col-label">包装方式</td>
				<td>
					<select name="sample_package_id" required="required">
						<?php 
foreach (\www\model\Sample::findOneByPk($sample->sample_id)->package_list as $v) {
    ?>
							<option value ="<?php 
    echo $v->id;
    ?>
"><?php 
    echo $v->pack_name;
    ?>
</option>
						<?php 
}
?>
					</select>
				</td>
			</tr>
			<tr>
Esempio n. 6
0
 public function searchSingleSample($get)
 {
     $sample = Sample::findOneByPk($get['id']);
     $tmp = SuiteSampleMapSingleSample::find('suite_sample_id = ?', $get['id'])->all(true);
     $single_sample_id_list = array_column($tmp, 'single_sample_id');
     $paginate = Paginate::instance();
     $paginate->setPageSize(8);
     if ($get['sample_no']) {
         $no = addslashes($get['sample_no']);
         $all_single_sample_list = Sample::find("sample_no LIKE '%{$no}%' AND sample_type=?", GlobalConf::SAMPLE_TYPE_SINGLE)->paginate($paginate);
     } else {
         $all_single_sample_list = Sample::find('sample_type=?', GlobalConf::SAMPLE_TYPE_SINGLE)->paginate($paginate);
     }
     return array('search' => $get, 'single_sample_id_list' => $single_sample_id_list, 'sample' => $sample, 'paginate' => $paginate, 'all_single_sample_list' => $all_single_sample_list);
 }