public function actionDel() { $result = 0; if ($_POST['BrandIDs']) { $str = ',' . $_POST['BrandIDs'] . ','; } $app = MakePromitBrand::model()->find('BrandName like "%' . $str . '%"'); if ($app) { $errorMsg = '该品牌已授权删除失败'; echo json_encode(array('success' => false, 'errorMsg' => $errorMsg)); exit; } else { $result = MakeGoodsBrand::model()->deleteByPk($_POST['BrandIDs']); if ($result > 0) { $errorMsg = '删除成功'; } else { $errorMsg = '删除失败'; } } echo json_encode(array('success' => $result > 0 ? true : false, 'errorMsg' => $errorMsg)); }
echo Yii::app()->createUrl("dealer/makequery/indexdetail/maker_id/" . $model['userID']); ?> '><?php echo $model['name']; ?> </a></td> <td ><?php echo $model['establish_year']; ?> 年成立</td> <td ><?php echo '¥ ' . $model['year_sales_volume']; ?> </td> <td><?php echo F::msubstr(MakeGoodsBrand::getBrands($model['userID'])); ?> </td> <td> <?php //echo $model['userID']; $cars = MakeOrganCarRelation::model()->findAll('userID =' . $model['userID']); $k = 1; foreach ($cars as $car) { if ($k == 1) { $makecar .= TransportMake::getMake($car['makeCode']) . ' ' . TransportCar::getCar($car['carCode']); } else { $makecar .= ',' . TransportMake::getMake($car['makeCode']) . ' ' . TransportCar::getCar($car['carCode']); } $k++; }
<table id="goods" style="height:510px"></table> <div id="maketoolbar"> <?php $organID = Commonmodel::getOrganID(); $cate = MakeGoodsBrand::model()->findAll('OrganID=:organID and UserID=:userID', array(':organID' => $organID, 'userID' => $organID)); $result = MakeGoodsCategory::model()->findAll('organID=:organID and userID=:userID', array(':organID' => $organID, ':userID' => $organID)); ?> <!-- 搜索 --> <div style="padding-left:12px;" id="quo_search"> <p class="form-row"> 商品编号: <input class="width98 input" name="goodsNO" id="goodsno"> 商品名称: <input class="width98 input" name="goodsName" id="goodsname"> OE号: <input class="width98 input" name="OENO" id="oe"> </p> <p class="form-row"> <label>商品品牌:</label> <?php echo CHtml::dropDownlist('GoodsBrand', '', CHtml::listData($cate, 'BrandID', 'BrandName'), array('class' => 'width110 select', 'empty' => '请选择品牌', 'id' => 'goodsbrand')); ?> <label>商品类别:</label> <?php echo CHtml::dropDownlist('GoodsCategory', '', CHtml::listData($result, "id", "name"), array('class' => 'width110 select', 'empty' => '请选择类别', 'id' => 'goodscategory')); ?> <!-- <label> 时间段:</label> <input class="easyui-datebox" type="text" style="width:88px" name="begintime" id="begintime">-<input class="easyui-datebox" type="text" style="width:88px" name="endtime" id="endtime"> --> <label>适用车型: </label><input class="width98 input" name="carmodel" id="carmodel"> </p> <p class="form-row"> <label> 配件品类:</label> <?php $res = Commonmodel::Getcpnames();
/** * 商品编号接口 */ public static function GetGoodsByGoodsNo($goodsno, $manufacturer_ID) { try { //$userID=Yii::app()->user->id; //$dealerID=Dealer::model()->find('userID=:userID',array(':userID'=>$userID)); //$grade=MakeEmpowerDealer::model()->find('up_userID=:up_userID and dealer_id=:dealer_id',array(':up_userID'=>$manufacturer_ID,':dealer_id'=>$dealerID->id)); // $sql=" select distinct a.id as goodsID,a.oe as OE, a.brand as brand ,a.NewVersion as verion_name,b.goodsno as goodsno,b.name as goodsname,b.price as makretprice," // ."b.price".$grade->grade." as goodsprice," // ." (select f.code from tbl_parts_level f where b.parts_level=f.id) as parts_level," // ." (select e.cp_name from tbl_goods_standard e where e.id=d.standard_id) as cp_name," // ." (select c.name from tbl_goods_category c where c.id=a.category_id and a.manufacturer_id=c.manufacturer_id) as category" // //." (select n.car from tbl_goods_vehicle m,tbl_vehicle n where m.Goods_ID='$goodsID' and n.VehicleID in (m.VehicleID)) as car" // ." from tbl_goods a ,tbl_goods_version b,tbl_goods_template d,tbl_vehicle n" // .' where a.id=b.goods_id and a.NewVersion=b.version_name' // ." and b.templet_id=d.id" // ." and a.manufacturer_id=b.manufacturer_id" // ." and a.ISdelete='N' and a.IsSale='Y' " // ." and a.manufacturer_id=$manufacturer_ID " // ." and a.id=$goodsID" // ." group by a.id order by a.id desc"; //$sql=" select distinct a.id as goodsID ,a.oe as OE,a.brand as brand,a.NewVersion as verion_name,b.goodsno as goodsno,b.name as goodsname,b.price as marketprice," // ."b.price".$grade->grade." as goodsprice," // ." (select distinct f.code from tbl_parts_level f where b.parts_level=f.id) as parts_level," // ." (select distinct e.cp_name from tbl_goods_standard e where e.id=d.standard_id) as cp_name," // ." (select distinct c.name from tbl_goods_category c where c.id=a.category_id and a.manufacturer_id=c.manufacturer_id) as category" // ." from tbl_goods a ,tbl_goods_version b,tbl_goods_category c,tbl_goods_template d,tbl_goods_standard e,tbl_parts_level f,tbl_goods_values g" // .' where a.id=b.goods_id and a.NewVersion=b.version_name' // ." and b.parts_level=f.id" // ." and b.templet_id=d.id" // ." and e.id=d.standard_id" // ." and a.category_id=c.id" // ." and b.values_id = g.id" // ." and a.manufacturer_id=b.manufacturer_id" // ." and a.ISdelete='N' and a.IsSale='Y'" // ." and a.manufacturer_id='$manufacturer_ID' "; // $sql.=" and b.goodsno='{$goodsno}'"; // $sql.=" group by a.id order by a.id desc"; //授权品牌 $organID = Commonmodel::getOrganID(); $brands = MakePromitBrand::model()->find('DealerID=' . $organID . ' and OrganID=' . $manufacturer_ID); $sql2 = "select distinct a.id as goodsID ,b.goods_category as category_id,b.goods_oe as OE,b.goods_brand as brand,b.organID,\n \t\t \t a.NewVersion as verion_name,b.goods_no as goodsno,b.goods_name as goodsname,\n b.benchmarking_brand,b.benchmarking_sn,a.create_time,d.Price," . " b.inventory as inventory,b.senddays,b.description,a.IsSale,b.standard_id" . " from tbl_make_goods a ,tbl_make_goods_version b ,tbl_make_goods_vehicle c,tbl_make_price_relation d" . ' where a.id=b.goods_id and a.NewVersion=b.version_name' . " and a.ISdelete='0' and b.ISdelete=0" . " and a.organID='{$manufacturer_ID}' and b.goods_no='{$goodsno}'"; $identity = Commonmodel::getIdentity(Yii::app()->user->id); if ($identity['identity'] == 2 && $brands['CustomerType']) { $sql2 .= " and d.TypeID= {$brands['CustomerType']} and d.GoodsID=a.id and d.Price is not null and a.IsSale=0"; } $result = Yii::app()->db->createCommand($sql2)->queryRow(); if ($result) { //查询品牌名称 $brandmodel = MakeGoodsBrand::model()->findByPK($result['brand']); $result['brand'] = $brandmodel['BrandName']; //商品销售价 if ($result['Price']) { $result['goodsprice'] = $result['Price']; } //$result['goodsprice']=sprintf("%.2f", $result['salesprice'] * $ratio / 100); } return $result; } catch (CDbException $e) { throw CDbException($e); } }
public function Getbrand($data) { $ids = explode(',', $data); $ids = array_filter($ids); $substr = ''; if (is_array($ids)) { foreach ($ids as $v) { $app = MakeGoodsBrand::model()->find('BrandID=' . $v); if ($substr) { $substr .= ',' . $app->BrandName; } else { $substr .= $app->BrandName; } } $substr = '<a title="' . $substr . '">' . $substr . '</a>'; } return $substr; }
<th field="Payment" width="80">结算方式</th> <th field="BrandName" width="120" align="left">授权品牌</th> <th field="PromitArea" width="120">授权地域</th> <th field="Phone" width="100">联系电话</th> </tr> </thead> </table> <div id="toolbar"> <div style="padding-left:12px;"> <!--<form id="searchpromit" method="post">--> <p class="form-row"> <span>机构名称:<input type="text" name="searchorganName" class="width108 input "/></span> <span style="margin-left:30px">授权品牌: <?php $barnd = MakeGoodsBrand::model()->findAll('OrganID=:OrganID', array(':OrganID' => Commonmodel::getOrganID())); $operate_region = CHtml::listData($barnd, "BrandID", "BrandName"); ?> <?php echo CHtml::dropDownList('searchBrandName', '', $operate_region, array('class' => 'width120 select', 'empty' => '请选择授权品牌')); ?> </span> <span style="margin-left:30px">授权地域:<?php $operate_data = Area::model()->findAll("grade=:grade", array(":grade" => 1)); $operate_region = CHtml::listData($operate_data, "id", "name"); ?> <?php echo CHtml::dropDownList('searchPromitArea', '', $operate_region, array('class' => 'width120 select', 'empty' => '请选择授权地域')); ?> </span> </p>
public function actionExportprice() { $type = $this->getCustomtype(); $get = $this->getPriceresult(); $result = $get['result']; //客户类别搜索 foreach ($type as $v) { $atype[$v['TypeID']] = $v; } if (!empty($_GET['ctype'])) { $type = array(); $temp = explode(',', $_GET['ctype']); foreach ($atype as $k => $v) { if (in_array($k, $temp)) { $type[$k]['TypeID'] = $k; $type[$k]['TypeName'] = $atype[$k]['TypeName']; } } } //导出 $objectPHPExcel = new PHPExcel(); $objectPHPExcel->setActiveSheetIndex(0); $objectPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20); $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A3', '商品编号(必填)'); $objectPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20); $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B3', '商品品牌'); $objectPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20); $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C3', '标准名称'); $cell = 'C'; foreach ($type as $k => $v) { $cell++; $objectPHPExcel->getActiveSheet()->getColumnDimension($cell)->setWidth(20); $objectPHPExcel->setActiveSheetIndex(0)->setCellValue($cell . '3', $v['TypeName']); } //报表头的输出 $objectPHPExcel->getActiveSheet()->mergeCells('A1:' . $cell . '1'); $objectPHPExcel->getActiveSheet()->setCellValue('A1', '客户价格表'); $objectPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getFont()->setSize(24); $objectPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objectPHPExcel->getActiveSheet()->mergeCells('A2:' . $cell . '2'); $objectPHPExcel->getActiveSheet()->setCellValue('A2', '*注:请勿更改表头字段,防止改价失败!可按要求添加或删除商品数据。'); //设置行高 $objectPHPExcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(25); $objectPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40); $objectPHPExcel->getActiveSheet()->getRowDimension('2')->setRowHeight(22); $objectPHPExcel->getActiveSheet()->getRowDimension('3')->setRowHeight(30); $objectPHPExcel->getActiveSheet()->getStyle('A3:' . $cell . '3')->getFont()->setBold(true); //设置居中 $objectPHPExcel->getActiveSheet()->getStyle('A3:' . $cell . '3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objectPHPExcel->getActiveSheet()->getStyle('A3:' . $cell . '3')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $n = 0; foreach ($result as $val) { // $objectPHPExcel->getActiveSheet()->setCellValue('A'.($n+4) ,($n+1)); $objectPHPExcel->getActiveSheet()->setCellValue('A' . ($n + 4), $val['goodsno']); //查询商品类别 $val['brandname'] = ''; if (!empty($val['brand'])) { $brand = MakeGoodsBrand::model()->findByPK($val['brand']); $val['brandname'] = $brand['BrandName']; } $objectPHPExcel->getActiveSheet()->setCellValue('B' . ($n + 4), $val['brandname']); //查询标准名称 $val['cp_name'] = ''; if (!empty($val['standard_id'])) { $stand = Gcategory::model()->findByPk($val['standard_id']); $val['cp_name'] = $stand['name']; } $objectPHPExcel->getActiveSheet()->setCellValue('C' . ($n + 4), $val['cp_name']); $sql2 = "select Price,TypeID from tbl_make_price_relation where GoodsID={$val['goodsID']}"; $price = DBUtil::queryAll($sql2); $pArr = array(); if (!empty($price)) { foreach ($price as $v1) { $pArr[$v1['TypeID']] = $v1['Price']; } } $cel = 'C'; foreach ($type as $k => $v2) { $cel++; if (array_key_exists($v2['TypeID'], $pArr)) { $objectPHPExcel->getActiveSheet()->setCellValue($cel . ($n + 4), $pArr[$v2['TypeID']]); } else { $objectPHPExcel->getActiveSheet()->setCellValue($cel . ($n + 4), ''); } } //设置边框 $currentRowNum = $n + 4; $objectPHPExcel->getActiveSheet()->getStyle('A' . ($n + 4) . ':' . $cel . $currentRowNum)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objectPHPExcel->getActiveSheet()->getStyle('A' . ($n + 4) . ':' . $cel . $currentRowNum)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $n++; } //导出为excel表格 $objectPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true); $objectPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false); ob_end_clean(); ob_start(); header('Content-Type : application/vnd.ms-excel'); header('Content-Disposition:attachment;filename="' . iconv("utf-8", "gb2312", "客户价格表") . '.xls"'); $objWriter = PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel5'); $objWriter->save('php://output'); }