示例#1
0
 /**
  * 创建订单
  */
 public function actionCreateorder()
 {
     $userID = Commonmodel::getOrganID();
     $order_no = time() . rand(2, 100) . $userID;
     // 订单编号
     $make_id = '3';
     // 卖家
     $dealer_id = $userID;
     // 买家
     $stauts = 10;
     $addtime = time();
     //生成订单
     $bool = Yii::app()->db->createCommand()->insert('tbl_dealer_order', array('order_no' => $order_no, 'maker_id' => $make_id, 'dealer_id' => $dealer_id, 'status' => $stauts, 'add_time' => $addtime));
     // 生成的订单ID
     $orderid = Yii::app()->db->getLastInsertID();
     // 购买的商品
     $tempgoods = DealerTempGoods::model()->findAll('user_id=:userid', array(':userid' => $userID));
     foreach ($tempgoods as $goods) {
         //生成订单商品
         $bool = Yii::app()->db->createCommand()->insert('tbl_dealer_order_goods', array('order_id' => $orderid, 'goods_id' => $goods['goods_id'], 'goods_no' => $goods['goods_no'], 'name' => $goods['name'], 'brand_id' => $goods['brand_id'], 'price' => $goods['price'], 'parts_level' => $goods['parts_level'], 'quantity' => $goods['quantity']));
     }
     if ($bool) {
         $id = $_GET['promID'];
         $count = DealerTempGoods::model()->deleteAll('id IN (' . $id . ')');
         if ($count > 0) {
             $bool = true;
         } else {
             $bool = false;
         }
     }
     echo $bool;
 }
示例#2
0
 public function actionModify()
 {
     $id = intval($_GET['id']);
     // $manufacturer_id=Yii::app()->user->id;
     $manufacturer_id = Commonmodel::getOrganID();
     $model = new GoodsTemplate();
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'templatemodify-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     $sql = "select a.name,a.Column1,a.Column2,a.Column3,a.Column4,a.Column5,b.cp_name,a.standard_id,b.system_type from tbl_goods_template a,tbl_goods_standard b " . " where b.id=a.standard_id and a.id={$id} and manufacturer_id= {$manufacturer_id}";
     $result = DBUtil::query($sql);
     $model->system_type = $result['system_type'];
     $model->cpname = $result['standard_id'];
     if (isset($_POST['GoodsTemplate'])) {
         $model->attributes = $_POST['GoodsTemplate'];
         $name = $_POST['GoodsTemplate']['name'];
         $Column1 = $_POST['GoodsTemplate']['Column1'];
         $Column2 = $_POST['GoodsTemplate']['Column2'];
         $Column3 = $_POST['GoodsTemplate']['Column3'];
         $Column4 = $_POST['GoodsTemplate']['Column4'];
         $Column5 = $_POST['GoodsTemplate']['Column5'];
         $standard_id = $_POST['GoodsTemplate']['cpname'];
         $result = $model->updateByPk($id, array('name' => $name, 'Column1' => $Column1, 'Column2' => $Column2, 'Column3' => $Column3, 'Column4' => $Column4, 'Column5' => $Column5, 'standard_id' => $standard_id));
         Yii::app()->user->setFlash('success', '修改成功');
         $this->refresh();
     }
     //所有常用配件
     $sql = "select distinct system_type,id from tbl_goods_standard where system_type is not null group by system_type";
     $parts = Yii::app()->db->createCommand($sql)->queryAll();
     $this->render('modify', array('model' => $model, 'result' => $result, 'parts' => $parts));
 }
示例#3
0
文件: Commonmodel.php 项目: zwq/unpei
 public static function getOrganName()
 {
     $organName = Yii::app()->user->getState('organName');
     if ($organName) {
         return $organName;
     }
     //先获取角色身份(生产商/经销商/修理厂)
     $organName = "";
     // $userid = Yii::app()->user->id;
     $userid = Commonmodel::getOrganID();
     $model = self::getIdentity($userid);
     if ($model['identity'] == 1) {
         $organ = MakeOrgan::model()->find('userID=:userid', array(':userid' => $userid));
         $organName = $organ['name'];
     } else {
         if ($model['identity'] == 2) {
             $organ = Dealer::model()->find('userID=:userid', array(':userid' => $userid));
             $organName = $organ['organName'];
         } else {
             if ($model['identity'] == 3) {
                 $organ = Service::model()->find('userId=:userid', array(':userid' => $userid));
                 $organName = $organ['serviceName'];
             }
         }
     }
     Yii::app()->user->setState('organName', $organName);
     return $organName;
 }
示例#4
0
文件: CommonForm.php 项目: zwq/unpei
 /**
  * 登记入库
  */
 public function Add($modelName, $return)
 {
     $user_id = Commonmodel::getOrganID();
     if ($_POST[$modelName]) {
         $post = $_POST[$modelName];
         if ($modelName == 'MakeEmpowerDealer') {
             $make = MakeEmpowerDealer::model()->findByPk($post['id']);
             if (empty($make)) {
                 $telephone = $_POST['telephone'];
                 $dealer = Dealer::model()->find("Phone='{$telephone}'");
                 if (empty($dealer)) {
                     Yii::app()->db->createCommand()->insert('tbl_user', array('username' => $telephone, 'password' => md5($telephone), 'email' => $telephone . '@jiaparts.com', 'status' => '1', 'create_at' => date('Y-m-d H-i-s', time()), 'identity' => '2'));
                     $newuserID = Yii::app()->db->getLastInsertID();
                     Yii::app()->db->createCommand()->insert('tbl_profiles', array('user_id' => $newuserID));
                     Yii::app()->db->createCommand()->insert('tbl_dealer', array('userID' => $newuserID, 'organName' => $post['organName'], 'jiapartsId' => $telephone, 'loginPassword' => md5($telephone), 'Phone' => $telephone));
                     $post['dealer_id'] = Yii::app()->db->getLastInsertID();
                 } else {
                     $post['dealer_id'] = $dealer->id;
                 }
                 $make = new MakeEmpowerDealer();
             }
             $post['up_userID'] = $user_id;
         } elseif ($modelName == 'MakeContacts') {
             $make = MakeContacts::model()->findByPk($post['id']);
             if (empty($make)) {
                 $make = new MakeContacts();
             }
             $post['up_userID'] = $user_id;
         } elseif ($modelName == 'MakeDistributionBusiness') {
             $make = MakeDistributionBusiness::model()->findByPk($post['id']);
             if (empty($make)) {
                 $make = new MakeDistributionBusiness();
             }
             $post['up_userID'] = $user_id;
         } elseif ($modelName == 'MakeStorageService') {
             $make = MakeStorageService::model()->findByPk($post['id']);
             if (empty($make)) {
                 $make = new MakeStorageService();
             }
             $post['up_userID'] = $user_id;
         } elseif ($modelName == 'MakeTechniqueService') {
             $make = MakeTechniqueService::model()->findByPk($post['id']);
             if (empty($make)) {
                 $make = new MakeTechniqueService();
             }
             $post['up_userID'] = $user_id;
             $post['serviceTime'] = $_POST['beginWeek'] . '至' . $_POST['endWeek'] . ' ' . $_POST['beginHour'] . '-' . $_POST['endHour'];
         }
         $make->attributes = $post;
         $make->save();
         $this->redirect(array($return));
     }
 }
示例#5
0
 public function actionMaintainlist()
 {
     $userID = Commonmodel::getOrganID();
     $criteria = new CDbCriteria();
     $criteria->with = "owners";
     if ($_GET) {
         if ($_GET['name']) {
             $remind = $this->getRecord($_GET['name']);
             $criteria->addInCondition('t.ID', $remind);
         }
         if ($_GET['status']) {
             $criteria->addCondition("t.Status = {$_GET['status']}", "AND");
         }
         if ($_GET['date']) {
             $starttime = strtotime($_GET['date']);
             $endtime = (int) (strtotime($_GET['date']) + 60 * 60 * 24);
             $criteria->addBetweenCondition('t.MaintainDate', $starttime, $endtime, "AND");
         }
     }
     $criteria->order = "t.MaintainDate DESC,t.UpdateTime DESC";
     //排序条件:t.MaintainDate,t.UpdateTime倒叙
     $criteria->addCondition("t.OrganID = {$userID}", "AND");
     $count = MaintainRemind::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = $_GET['rows'];
     $pages->applyLimit($criteria);
     $model = MaintainRemind::model()->findAll($criteria);
     foreach ($model as $key => $value) {
         $data[$key]['ID'] = $value['ID'];
         if ($value['Status'] == '1') {
             $data[$key]['State'] = '待发送';
         } elseif ($value['Status'] == '2') {
             $data[$key]['State'] = '已发送';
         } else {
             $data[$key]['State'] = '取消发送';
         }
         $data[$key]['Status'] = $value['Status'];
         $data[$key]['MaintainDate'] = date('Y-m-d', $value['MaintainDate']);
         $data[$key]['MaintainTime'] = $value['MaintainDate'];
         $data[$key]['RemindContent'] = $value['RemindContent'];
         $data[$key]['Content'] = F::msubstr($value['RemindContent']);
         foreach ($value->owners as $owners_key => $owners_value) {
             $data[$key]['OldName'] .= $owners_value->Name . ",";
             $data[$key]['Name'] = F::msubstr(substr($data[$key]['OldName'], 0, -1));
         }
     }
     $rs = array('total' => $count, 'rows' => $data ? $data : array());
     echo json_encode($rs);
 }
示例#6
0
 public function actionGetservicer()
 {
     //订购平台
     $organID = Commonmodel::getOrganID();
     //待确认的报价单
     $result['dquotions'] = PapQuotation::model()->count(array('condition' => "status = 1 and ServiceID = {$organID}"));
     //待付款的订单
     $result['forder'] = PapOrder::model()->count(array('condition' => "Status = 1 and BuyerID = {$organID}"));
     //待收货的订单
     $result['torder'] = PapOrder::model()->count(array('condition' => "Status = 3 and BuyerID = {$organID}"));
     //异常订单
     $result['uorder'] = PapOrder::model()->count(array('condition' => "Payment=2 and Status not in (11,12,13,14) and IsUnusual!=0 and BuyerID = {$organID}"));
     //待买家退货的订单
     $ssorder1 = PapOrder::model()->count(array('condition' => "Payment=2 and Status = 12 and BuyerID = {$organID}"));
     $ssorder2 = PapOrder::model()->count(array('condition' => "Payment=1 and PayStatus = 'WAIT_BUYER_RETURN_GOODS' and BuyerID = {$organID}"));
     $result['sorder'] = $ssorder1 + $ssorder2;
     echo json_encode($result);
 }
示例#7
0
 public function actionEdit()
 {
     //        $error=MakeGoodsBrand::model()->find('BrandName='.$_POST['BrandName']);
     //        if($error){
     //            echo json_encode(array('errorMsg'=>'该品牌已存在'));
     //            exit;
     //        }
     $i = false;
     if ($_GET['BrandID']) {
         $result = MakeGoodsBrand::model()->findByPK($_GET['BrandID']);
         if ($result->BrandName == $_POST['BrandName']) {
         } else {
             $error = MakeGoodsBrand::model()->find('BrandName=:BrandName && OrganID=:OrganID', array(':BrandName' => $_POST['BrandName'], ':OrganID' => Commonmodel::getOrganID()));
             if ($error) {
                 echo json_encode(array('errorMsg' => '该品牌已存在'));
                 exit;
             }
         }
         $_POST['UpdateTime'] = time();
         $app1 = MakeGoodsBrand::model()->updateByPk($_GET['BrandID'], $_POST);
         if ($app1) {
             $i = true;
         }
     } else {
         $error = MakeGoodsBrand::model()->find('BrandName=:BrandName && OrganID=:OrganID', array(':BrandName' => $_POST['BrandName'], ':OrganID' => Commonmodel::getOrganID()));
         if ($error) {
             echo json_encode(array('errorMsg' => '该品牌已存在'));
             exit;
         }
         $app = new MakeGoodsBrand();
         $app->attributes = $_POST;
         $app->CreateTime = time();
         $app->OrganID = Commonmodel::getOrganID();
         $app->UserID = Yii::app()->user->id;
         $app2 = $app->save();
         if ($app2) {
             $i = true;
         }
     }
     echo json_encode(array('success' => $i, 'errorMsg' => $i > 0 ? '操作成功' : '操作失败'));
 }
示例#8
0
 /**
  * 获取参数名称列名
  * @param type $cp_name 标准名称
  */
 private function getParamName($cp_name)
 {
     $standardid = $this->cpnameID($cp_name);
     $organID = Commonmodel::getOrganID();
     $datas = MakeGoodsTemplate::model()->findAll('organID=' . $organID . ' and ISdelete="N" and standard_id=' . $standardid);
     $paramsname = array();
     // 参数名称
     if ($datas) {
         foreach ($datas as $data) {
             $paramsname['_' . $data['id']] = $data['name'];
         }
     }
     return $paramsname;
 }
示例#9
0
文件: goodslist.php 项目: zwq/unpei
            &nbsp;&nbsp;<label>商品品牌:</label>
            <?php 
echo CHtml::dropDownlist('GoodsBrand', '', CHtml::listData($cate, 'BrandID', 'BrandName'), array('class' => 'width110 select', 'empty' => '请选择品牌', 'id' => 'goodsbrand'));
?>
            &nbsp;&nbsp;&nbsp;&nbsp;<label>商品类别:</label>
            <?php 
echo CHtml::dropDownlist('GoodsCategory', '', CHtml::listData($result, "id", "name"), array('class' => 'width110 select', 'empty' => '请选择类别', 'id' => 'goodscategory'));
?>
            <!--            <label>&nbsp;&nbsp;时间段:</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">&nbsp;-->
            &nbsp;&nbsp;&nbsp;&nbsp;<label>适用车型:&nbsp;&nbsp;</label><input class="width98 input" name="carmodel" id="carmodel">
        </p>
        <p class="form-row">
            <label>&nbsp;&nbsp;配件品类:</label>
            <?php 
$res = Commonmodel::Getcpnames();
$params = array('class' => 'width230 select', 'id' => 'leafCategorysearch');
if (!$res['cpnames']) {
    $params['empty'] = '请添加配件品类';
}
?>
            <?php 
echo CHtml::dropDownlist('leafCategorysearch', $res['firstcpname'], $res['cpnames'], $params);
?>
 
            <label style="margin-left:10px">&nbsp;&nbsp;上/下架: </label>
            <select name="IsSale" class="width100 select" id="issale">
                <option value="">全部</option>
                <option value="0">上架</option>
                <option value="1">下架</option>
            </select>
示例#10
0
 public function postItrregister()
 {
     $postdata = file_get_contents("php://input");
     if (!empty($postdata)) {
         $inputid = Input::get('userId');
         $itr_name = Input::get('name');
         $itr_pan = Input::get('pan');
         $itr_bankstatement = Input::get('bankstatement');
         $itr_form16 = Input::get('form16');
         $itr_tdscertificate = Input::get('tds');
         $itr_addrproof = Input::get('addrproof');
         $itr_previtr = Input::get('itrcopy');
         $itr_bankname = Input::get('bankacname');
         $itr_bankacctype = Input::get('actype');
         $itr_bankaccno = Input::get('accno');
         $itr_bankifsc = Input::get('ifsccode');
         $itr_fyear = Input::get('fyear');
         $itr_mobileno = Input::get('mobileno');
         $itr_email = Input::get('email');
         $itr_createdby = Input::get('userId');
         $itr_createdat = Commonmodel::dateandtime();
         $itr_status = 1;
         $itr_clientip = Input::get('clientip');
         //	echo $itr_name,"<br/>", $itr_pan ,"<br/>", $itr_bankstatement; exit;
         if ($itr_name != '' && $itr_pan != '' && $itr_bankstatement != '' && $itr_addrproof != '' && $itr_mobileno != '' && $itr_email != '') {
             $detectyear = Itr::where('itr_mobileno', '=', $itr_mobileno)->pluck('itr_createdat');
             $enreytear = Commonmodel::detectyear($itr_createdat);
             $currentyear = Commonmodel::detectyear($detectyear);
             if ($enreytear == $currentyear) {
                 return Response::json(array('status' => 'failure', 'message' => 'You have Already Applyied For IRT this year'));
             } else {
                 $checkbalance = Userfinance::where('ufin_user_id', '=', $inputid)->where('ufin_main_balance', '<', '100')->get();
                 $getbalance = Userfinance::where('ufin_user_id', '=', $inputid)->pluck('ufin_main_balance');
                 if (count($checkbalance) > 0) {
                     return Response::json(array('status' => 'failure', 'message' => 'You Do not Have Sufficient Balance TO Apply for IRT'));
                 } else {
                     $input = array('itr_name' => $itr_name, 'itr_pan' => $itr_pan, 'itr_bankstatement' => $itr_bankstatement, 'itr_form16' => $itr_form16, 'itr_tdscertificate' => $itr_tdscertificate, 'itr_addrproof' => $itr_addrproof, 'itr_previtr' => $itr_previtr, 'itr_bankname' => $itr_bankname, 'itr_bankacctype' => $itr_bankacctype, 'itr_bankaccno' => $itr_bankaccno, 'itr_bankifsc' => $itr_bankifsc, 'itr_fyear' => $itr_fyear, 'itr_mobileno' => $itr_mobileno, 'itr_email' => $itr_email, 'itr_createdby' => $itr_createdby, 'itr_createdat' => $itr_createdat, 'itr_status' => $itr_status, 'itr_clientip' => $itr_clientip);
                     $obj = new Itr();
                     $obj->create($input);
                     $getbalance = $getbalance - 99;
                     $balance = array('ufin_main_balance' => $getbalance);
                     Userfinance::where('ufin_user_id', $inputid)->update($balance);
                     return Response::json(array('status' => 'Success', 'message' => 'Your PAN Card Details Have been Registered Successfully'));
                 }
             }
         } else {
             return Response::json(array('status' => 'failure', 'message' => 'Fill all manditary fields'));
         }
     } else {
         return Response::json(array('status' => 'failure', 'message' => 'Fill all manditary fields'));
     }
 }
示例#11
0
 public function actionCheckcar()
 {
     $organID = Commonmodel::getOrganID();
     $criteria = new CDbCriteria();
     $criteria->with = "owner";
     $criteria->addCondition("t.OrganID = {$organID}");
     $criteria->addSearchCondition('t.LicensePlate', "{$_POST['licenseplate']}", "AND");
     $model = CarInfo::model()->findAll($criteria);
     foreach ($model as $key => $value) {
         //车辆ID
         $data[$key]['ID'] = $value['ID'];
         //车主信息
         $data[$key]['Name'] = $value->owner->Name ? F::msubstr($value->owner->Name) : '未绑定';
         $data[$key]['Phone'] = $value->owner->Phone ? F::msubstr($value->owner->Phone) : '未绑定';
         $data[$key]['City'] = $value->owner->City ? F::msubstr(str_replace("/", "", $value->owner->City)) : '未绑定';
         //车辆信息
         $data[$key]['LicensePlate'] = F::msubstr($value['LicensePlate']);
         if ($value['UseNature'] == '1') {
             $data[$key]['Uses'] = "私家车";
         } elseif ($value['UseNature'] == '2') {
             $data[$key]['Uses'] = "公务车";
         } else {
             $data[$key]['Uses'] = "运营车辆";
         }
         $data[$key]['Car'] = F::msubstr(str_replace(",", "", $value['Car']));
         $data[$key]['VinCode'] = $value['VinCode'];
         $data[$key]['Miles'] = $value['Mileage'];
         $data[$key]['BuyTime'] = date('Y-m-d', $value['BuyTime']);
     }
     $rs = array('totals' => count($model), 'rows' => $data ? $data : array());
     echo json_encode($rs);
 }
 public function postRefund()
 {
     $postdata = Input::all();
     $panIDPK = Input::get('pan_id_pk');
     $currenttime = Commonmodel::dateandtime();
     if (!$panIDPK) {
         return Response::json(array('status' => "failed", 'message' => 'Please send a PAN ID'));
     } else {
         $findrefuncid = Panoffiline::find($panIDPK);
         if ($findrefuncid) {
             $getcurrentuser = Panoffiline::where('pan_id_pk', '=', $panIDPK)->pluck('pan_created_by');
             $response = Panoffiline::where('pan_id_pk', $panIDPK)->get();
             if ($response) {
                 foreach ($response as $res) {
                     $userfinID = $res->pan_created_by;
                     $panCoupenNo = $res->pan_coupon_no;
                     $mainBalance = Userfinance::where('ufin_user_id', $userfinID)->pluck('ufin_main_balance');
                     $panTotBal = $mainBalance + 106;
                     $balanceDebit = array('ufin_main_balance' => $panTotBal);
                     if ($panCoupenNo != '0') {
                         Userfinance::where('ufin_user_id', '=', $userfinID)->update($balanceDebit);
                         $coupenReset = array('pan_coupon_no' => '');
                         Panoffiline::where('pan_id_pk', '=', $panIDPK)->update($coupenReset);
                         $panCoupenUpdate = array('pc_coupon_no' => $panCoupenNo);
                         $procode = Products::where('prod_short_name', '=', 'PANM')->pluck('prod_code');
                         $panledger = array('lr_date' => $currenttime, 'lr_trans_type' => 'CR', 'lr_comment' => 'Pan Refund', 'lr_credit_amount' => '106', 'lr_post_balance' => $panTotBal, 'lr_created_by' => $getcurrentuser, 'lr_prod_code' => $procode);
                         $panlegcreta = new Ledgerreport();
                         $panlegcreta->create($panledger);
                         $coupen = new Coupons();
                         $coupen->create($panCoupenUpdate);
                         return Response::json(array('status' => "success", 'message' => 'Amount debited successfully'));
                     } else {
                         return Response::json(array('status' => "failure", 'message' => 'PAN Card has been already applied for refund'));
                     }
                 }
             }
         } else {
             return Response::json(array('status' => "failure", 'message' => 'No User found for this ID'));
         }
     }
 }
示例#13
0
文件: tabs.php 项目: zwq/unpei
<?php

$controlerId = Yii::app()->getController()->id;
$actionId = $this->getAction()->getId();
$active = "class = 'active'";
$organID = Commonmodel::getOrganID();
$res = User::model()->findByPk($organID);
?>


<div class='tabs' pre='tab'>
    <a class='left-indent'>&nbsp;</a>
    <a <?php 
if ($actionId == 'index') {
    echo $active;
}
?>
 href="<?php 
echo Yii::app()->createUrl('cim/discountset/index');
?>
">商城订单</a>
    <a <?php 
if ($actionId == 'inquiry') {
    echo $active;
}
?>
 href="<?php 
echo Yii::app()->createUrl('cim/discountset/inquiry');
?>
">询价单订单</a>
    <a <?php 
示例#14
0
文件: Goods.php 项目: zwq/unpei
 /**
  * 商品编号接口
  */
 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);
     }
 }
示例#15
0
 private function checkgoodno()
 {
     $organID = Commonmodel::getOrganID();
     $sql = "select a.id, b.goods_no from tbl_make_goods a,tbl_make_goods_version b \n    \twhere a.organID={$organID} and a.IsSale='0' and a.ISdelete='0' \n    \tand a.id=b.goods_id and a.NewVersion=b.version_name and b.organID={$organID} \n    \tand b.ISdelete='0'\n    \t";
     $datas = array();
     $res = DBUtil::queryAll($sql);
     foreach ($res as $key => $val) {
         $datas[$val['id']] = $val['goods_no'];
     }
     return $datas;
 }
示例#16
0
 public function actionDeltitle()
 {
     if (!isset($_GET['do']) || $_GET['do'] != 'unipei') {
         echo '你没有权限访问!';
         return;
     }
     $OrganID = Commonmodel::getOrganID();
     $sql = "update pap_goods set Title ='' where OrganID = " . $OrganID;
     $bool = Yii::app()->papdb->createCommand($sql)->execute();
     if ($bool) {
         echo "清楚成功";
         var_dump($bool);
     } else {
         echo '清除失败';
     }
 }
示例#17
0
 /**
  * 获取购买服务记录
  */
 public function actionGetpushbuyrecord()
 {
     $organID = Commonmodel::getOrganID();
     $criteria = new CDbCriteria();
     $criteria->order = "ID DESC";
     $criteria->condition = "OrganID = {$organID}";
     $payway = $_GET['payway'];
     $sendway = $_GET['sendway'];
     $month = $_GET['month'];
     if (!empty($month)) {
         $recomtime = time();
         if ($month == 1) {
             // 1个月
             $recomtime -= 24 * 60 * 60 * 30 * 1;
         } elseif ($month == 3) {
             // 3个月
             $recomtime -= 24 * 60 * 60 * 30 * 3;
         } elseif ($month == 6) {
             // 6个月
             $recomtime -= 24 * 60 * 60 * 30 * 6;
         } elseif ($month == 12) {
             // 1年
             $recomtime -= 24 * 60 * 60 * 30 * 12;
         } else {
             $recomtime -= 24 * 60 * 60 * 30 * 44;
         }
         $criteria->addCondition("t.CreateTime >= {$recomtime} ", 'and');
     }
     if (!empty($sendway)) {
         $criteria->addCondition("t.PushType = {$sendway}", 'and');
     }
     if (!empty($payway)) {
         $criteria->addCondition("t.PayWay = {$payway}", 'and');
     }
     $count = PushbuyRecord::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = $_GET['rows'];
     $pages->applyLimit($criteria);
     $pushrecords = PushbuyRecord::model()->findAll($criteria);
     $pushrecord = array();
     foreach ($pushrecords as $key => $value) {
         $pushrecord[$key]['ID'] = $value['ID'];
         $pushrecord[$key]['PushType'] = $value['PushType'] == 1 ? '邮件' : '短信';
         $pushrecord[$key]['Count'] = $value['Count'];
         $pushrecord[$key]['PayWay'] = $this->payway($value['PayWay']);
         $pushrecord[$key]['Amount'] = '¥ ' . $value['Amount'];
         $pushrecord[$key]['CreateTime'] = date('Y年m月d日', $value['CreateTime']);
     }
     $rs = array('total' => $count, 'rows' => $pushrecord);
     echo json_encode($rs);
 }
示例#18
0
 /**
  * 自定义验证规则 机构名称不能为空
  */
 public function uniqueName()
 {
     if (!$this->hasErrors('Name')) {
         $organID = Commonmodel::getOrganID();
         if (!$this->ID) {
             $model = self::model()->findAll("OrganID=:OrganID and Name=:name", array(':OrganID' => $organID, ':name' => $this->Name));
         } else {
             $model = self::model()->findAll("OrganID=:OrganID and Name=:name and ID!=:id", array(':OrganID' => $organID, ':name' => $this->Name, ':id' => $this->ID));
         }
         if (!empty($model)) {
             $this->addError('Name', '该配送商名称已存在');
         }
     }
 }
示例#19
0
 public function actionUpdatelogistics()
 {
     $id = trim($_GET['ID']);
     $organID = Commonmodel::getOrganID();
     $model = Logistics::model()->findByPk($id);
     if (isset($_POST)) {
         $attributes['LogisticsDescription'] = $_POST['LogisticsDescription'];
         $model->attributes = $attributes;
         $model->LogisticsCompany = $_POST['LogisticsCompany'];
         $model->OrganID = $organID;
         $model->CreateTime = time();
         $model->UpdateTime = time();
         $model->Status = 2;
         //状态为2是经销商物流
         $bool = $model->save();
         if ($bool) {
             // 把地址添加到关系表里,可添加多个
             $sprovince = $_POST['province'];
             $scity = $_POST['city'];
             $sarea = $_POST['area'];
             $addlegth = count($sprovince);
             for ($i = 0; $i < $addlegth; $i++) {
                 $model1 = new LogisticsAddress();
                 $model1->LogisticsID = $id;
                 $model1->Province = $sprovince[$i];
                 $model1->City = $scity[$i];
                 $model1->Area = $sarea[$i];
                 $model1->save();
             }
         }
         if ($bool) {
             $rs = array('success' => 1, 'errorMsg' => '物流公司修改成功');
         } else {
             $rs = array('success' => 0, 'errorMsg' => '物流公司修改失败');
         }
     }
     echo json_encode($rs);
 }
示例#20
0
 public function actionPapeva()
 {
     $evarr = array();
     $evarr = EvaluateService::getevainfo(3);
     $this->pageTitle = Yii::app()->name . '-' . "添加评价";
     $OrderID = Yii::app()->request->getParam('order');
     //订单ID  传递前台(input)
     if ($OrderID) {
         $Status = $_GET['Status'];
         //订单状态
         $BuyerID = $_GET['BuyerID'];
         //买家ID
         $EvaStatus = $_GET['EvaStatus'];
         //评价状态
         $this->render('papeva', array('OrderID' => $OrderID, 'Status' => $Status, 'EvaStatus' => $EvaStatus, 'BuyerID' => $BuyerID, 'evarr' => $evarr));
         exit;
     } else {
         $Status = $_POST['Status'];
         $BuyerID = $_POST['BuyerID'];
         $OrderID = $_POST['evalOrderID'];
         $EvaStatus = $_POST['EvaStatus'] ? $_POST['EvaStatus'] : null;
         $OrganID = Commonmodel::getOrganID();
         $Message = Yii::app()->request->getParam('Evaluations');
         //            var_dump($Message);die;
         $evaID = Yii::app()->request->getParam('evaID');
         if (isset($_POST)) {
             $addsql = "insert into pap_evaluation_organ (Identity,OrganID,Recier,JudgeID,OrderID,Score,Message,CreateTime) values ";
             $keytop = 1;
             foreach ($evaID as $ekeys => $evalue) {
                 if ($keytop != 1) {
                     $addsql .= ",";
                 }
                 $addsql .= "(";
                 $addsql .= 3;
                 $addsql .= ",";
                 $addsql .= $OrganID;
                 $addsql .= ",";
                 $addsql .= $BuyerID;
                 $addsql .= ",";
                 $addsql .= $ekeys;
                 $addsql .= ",";
                 $addsql .= $OrderID;
                 $addsql .= ",";
                 $addsql .= $evalue;
                 $addsql .= ",'";
                 $addsql .= htmlspecialchars($Message);
                 $addsql .= "',";
                 $addsql .= time();
                 $addsql .= ")";
                 $keytop = 2;
                 //                    EvaluateService::addjudgerecord($ekeys, $evalue, $BuyerID, 3, $OrderID);
             }
             $bool = Yii::app()->papdb->createCommand($addsql)->execute();
             if ($bool) {
                 //获取被评价机构分数
                 $organScore = "select Recier,Score,OrderID from pap_evaluation_organ where OrganID={$OrganID} and OrderID=" . $OrderID;
                 $bool2 = Yii::app()->papdb->createCommand($organScore)->queryAll();
                 $sum = 0;
                 foreach ($bool2 as $v) {
                     $sum += $v['Score'];
                 }
                 //获取被评价的机构信用等级
                 $organGrade = "select Grade from jpd_organ where ID=" . $bool2[0]['Recier'];
                 $bool3 = Yii::app()->jpdb->createCommand($organGrade)->queryRow();
                 //更新被评价的机构信用等级
                 $sum2 = $sum + $bool3['Grade'];
                 $Gradesum = "update jpd_organ set Grade = {$sum2} where ID=" . $bool2[0]['Recier'];
                 $bool4 = Yii::app()->jpdb->createCommand($Gradesum)->execute();
                 if ($Status == 9 && $EvaStatus == null) {
                     $EvaStatus = 16;
                     //如果该订单经销商先评价,把状态改为16
                 } else {
                     if ($Status == 9 && $EvaStatus == 15) {
                         $EvaStatus = 20;
                         //如果该订单之前服务店评价过一次,则经销商此时评价状态改为20
                     }
                 }
                 $bool2 = PapOrder::model()->updateByPK($OrderID, array('EvaStatus' => $EvaStatus));
                 $rs = array('success' => 1, 'errorMsg' => '评价成功');
             } else {
                 $rs = array('success' => 0, 'errorMsg' => '评价失败');
             }
         }
     }
     $this->render("evaresult", array('result' => $rs));
 }
示例#21
0
 public function actionDelImgGoods()
 {
     $organID = Commonmodel::getOrganID();
     $GoodsID = $_GET['goodsid'];
     //         $sql = "delete from tbl_dealer_goods_image_relation  where OrganID = ".$organID." and GoodsID =".$GoodsID;
     $model = DealerGoodsImageRelation::model()->deleteAll("OrganID= '{$organID}' and GoodsID='{$GoodsID}'");
     if ($model) {
         $model = 1;
     }
     echo json_encode($model);
 }
示例#22
0
 public function actionShareapply()
 {
     //通过$_POST['ContactID']获取联系人信息
     $contact = $this->getContact(Yii::app()->request->getParam("ContactID"));
     //判断该共享机构是否与当前登录用户存在共享关系,存在则提示用户是否覆盖
     $share = BusinessShare::model()->find(array("condition" => "InitiatorID = {$contact['user_id']} and ShareID = {$contact['contact_user_id']} and Status = 1"));
     //向该机构的共享申请已存在,但尚未确认
     if ($share) {
         $result['exists'] = "已存在向该机构的申请记录,是否覆盖?";
         echo json_encode($result);
     } else {
         $type = explode(',', Yii::app()->request->getParam("ShareType"));
         if ($type[1]) {
             $ShareType = 3;
         } else {
             $ShareType = Yii::app()->request->getParam("ShareType");
         }
         $verify = Yii::app()->request->getParam("VerifyInfo");
         $model = new BusinessShare();
         $model->InitiatorID = $contact['user_id'];
         $model->InitiatorName = Commonmodel::getOrganName();
         $model->ShareID = $contact['contact_user_id'];
         $model->ShareName = $contact['companyname'];
         $model->ShareType = $ShareType;
         $model->VerifyInfo = $verify == "(验证信息不能超过64个字符)" ? '' : $verify;
         $model->Status = 1;
         $model->CreateTime = time();
         $model->UpdateTime = time();
         $success = $model->save();
         if ($success == 1) {
             $result['success'] = "共享申请发送成功!";
         } else {
             $result['errorMsg'] = "系统异常,共享申请发送失败!";
         }
         echo json_encode($result);
     }
 }
示例#23
0
 public function actionSharecontact()
 {
     $organID = Commonmodel::getOrganID();
     $dealer = Dealer::model()->find('userID=:userid', array(':userid' => $organID));
     $share = BusinessShare::model()->findAll('InitiatorID=:intorID and Status=2', array(':intorID' => $organID));
     foreach ($share as $key => $value) {
         $shareID .= ',' . $value['ShareID'];
     }
     $shareID = ltrim($shareID, ",");
     //查出shareID
     $sql = "select a.id,a.contact_user_id,a.customertype,\n\t\t   a.cooperationtype,a.name,a.sex,\n\t\t   a.companyname,a.phone,a.province,a.city,a.area,a.email,\n\t\t   a.weixin,a.QQ,a.create_time,a.Status,a.jiapart_ID,a.update_time,\n\t\t   (select b.category from tbl_customer_category b where a.customercategory=b.id and a.user_id={$organID}) as customercategory\n\t\t   from tbl_business_contacts a where \n\t\t   user_id='{$organID}' and Status=0  and a.contact_user_id in({$shareID})";
     if ($_POST) {
         $search['name'] = $_POST['name'];
         $search['phone'] = $_POST['phone'];
         $search['keyword'] = $_POST['keyword'];
         if ($search) {
             if ($search['name']) {
                 $sql .= " and name like'%{$search['name']}%'";
             }
             if ($search['phone']) {
                 $sql .= " and phone like '%{$search['phone']}%'";
             }
             if ($search['keyword']) {
                 $sql .= " and (companyname like '%{$search['keyword']}%') ";
             }
         }
     }
     $sql .= "order by create_time desc";
     $criteria = new CDbCriteria();
     $models = Yii::app()->db->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = intval($_GET['rows']);
     $pages->applylimit($criteria);
     $models = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $models->bindValue(':limit', $pages->pageSize);
     $models = $models->queryAll();
     foreach ($models as $key => $value) {
         $data[$key]['id'] = $value['id'];
         $data[$key]['Initiator'] = F::msubstr($dealer['organName']);
         $data[$key]['companyID'] = $value['contact_user_id'];
         //$data[$key]['customertype'] = $value['customertype'];
         $data[$key]['cooperationtype'] = $value['cooperationtype'];
         $data[$key]['customercategory'] = $value['customercategory'];
         $data[$key]['name'] = $value['name'];
         $data[$key]['sex'] = $value['sex'];
         $data[$key]['companyname2'] = F::msubstr($value['companyname']);
         $data[$key]['companyname'] = $value['companyname'];
         $data[$key]['phone'] = $value['phone'];
         $data[$key]['province'] = $value['province'];
         $data[$key]['city'] = $value['city'];
         $data[$key]['area'] = $value['area'];
         $data[$key]['address'] = F::msubstr(Area::getCity($value['province']) . Area::getCity($value['city']) . Area::getCity($value['area']));
         $data[$key]['email'] = $value['email'];
         $data[$key]['weixin'] = $value['weixin'];
         $data[$key]['QQ'] = $value['QQ'];
         $data[$key]['create_time'] = $value['create_time'];
         $data[$key]['Status'] = $value['Status'];
         $data[$key]['jiapart_ID'] = $value['jiapart_ID'];
         $data[$key]['update_time'] = $value['update_time'];
         //$data[$key]['checked']=true;
     }
     $rs = array('total' => $count, 'rows' => !empty($data) ? $data : array());
     echo json_encode($rs);
 }
示例#24
0
 public function actionSearch()
 {
     $sqldealer = "select dealer.id,dealer.BusinessScope,dealer.organName,dealer.jiapartsID,dealer.province,dealer.city,dealer.area,dealer.address,dealer.Phone,dealer.keyword,dealer.BusinessBrand,dealer.userID,dealer.ContactPhone from tbl_dealer as dealer ";
     $searchSql = " where !ISNULL(dealer.organName)";
     if (!empty($_GET['search'])) {
         $search = $_GET['search'];
         $search['mainCategory'] = $_GET['jpmall_maincate'];
         $search['subCategory'] = $_GET['jpmall_subcate'];
         $search['leafCategory'] = $_GET['jpmall_cpname'];
         $search['cpname'] = $_GET['cpname'];
         if (!empty($search['brand'])) {
             $searchSql .= " AND dealer.userID in (select brand.OrganID from tbl_dealer_brand as brand where brand.BrandName  like '%{$search['brand']}%' ) ";
         }
         if (!empty($search['province'])) {
             if (!empty($search['city']) && $search['city'] != '0') {
                 $searchSql .= " AND dealer.province = '{$search['province']}' AND dealer.city = '{$search['city']}'";
             } else {
                 $searchSql .= " AND dealer.province = '{$search['province']}'";
             }
         }
         if ($search['mainCategory'] && $search['subCategory'] && $search['leafCategory']) {
             $searchSql .= " AND dealer.userID in (select mogr.OrganID from tbl_dealer_cpname as mogr where\n                        (mogr.BigpartsID = '{$search['mainCategory']}' and mogr.SubCodeID = '' and mogr.CpNameID = '')\n                     or (mogr.BigpartsID = '{$search['mainCategory']}' and mogr.SubCodeID = '{$search['subCategory']}' and mogr.CpNameID = '')\n                     or (mogr.BigpartsID = '{$search['mainCategory']}' and mogr.SubCodeID = '{$search['subCategory']}' and mogr.CpNameID = '{$search['leafCategory']}'))";
         } elseif ($search['subCategory'] && $search['mainCategory']) {
             $searchSql .= " AND dealer.userID in (select mogr.OrganID from tbl_dealer_cpname as mogr where\n                     (mogr.BigpartsID = '{$search['mainCategory']}' and mogr.SubCodeID = '{$search['subCategory']}') \n                   or (mogr.BigpartsID = '{$search['mainCategory']}' and mogr.SubCodeID = '')) ";
         } elseif ($search['mainCategory']) {
             $searchSql .= " AND dealer.userID in (select mogr.OrganID from tbl_dealer_cpname as mogr where mogr.BigpartsID = '{$search['mainCategory']}' ) ";
         }
         if (!empty($search['payway'])) {
             //echo $search['payway'];
             // 查询授权的经销商ID
             $organID = Commonmodel::getOrganID();
             $sql = "select dealer_id from tbl_make_empower_dealer where up_userID = {$organID}";
             if ($search['payway'] == 2) {
                 // 未授权经销商
                 $searchSql .= " AND dealer.userID NOT IN (select ed.DealerID from tbl_make_promit_brand ed where ed.OrganID = {$organID} ) ";
             } else {
                 if ($search['payway'] == 3) {
                     // 授权经销商
                     $searchSql .= " AND dealer.userID IN (select ed.DealerID from tbl_make_promit_brand ed where ed.OrganID = {$organID} ) ";
                 }
             }
         }
         //			if(!empty($search['vehicleMake'])){
         //				$carcriteria=new CDbCriteria();
         //				if (!empty($search['vehicleModel'])){
         //					$carcriteria->addCondition("t.businessCar = '".$search['vehicleMake']."'",'AND');
         //					$carcriteria->addCondition("t.businessCarModel = '".$search['vehicleModel'])."'",'AND');
         ////					$searchSql.=" AND vehicle.businessCar = '".$search['vehicleMake']."' AND vehicle.businessCarModel= '".$search['vehicleModel']."'";
         //				}else {
         //					$carcriteria->addCondition("t.businessCar = '".$search['vehicleMake']."'",'AND');
         ////					$searchSql.=" AND vehicle.businessCar = '".$search['vehicleMake']."'";
         //				}
         //				$carcriteria->distinct=true;
         //				$carcriteria->select='t.userid';
         //				$carmodels=DealerVehicle::model()->findAll($carcriteria);
         //				if (!empty($carmodels)){
         //					foreach ($carmodels as $car){
         //						$users[]=$car->userid;
         //					}
         //				}
         //				$criteria->addInCondition('userID', $users);
         //			}
     }
     $sqldealer .= $searchSql;
     $pagesize = 10;
     $result = DBUtil::queryAll($sqldealer);
     $count = count($result);
     $pagess = 1;
     if ($count % $pagesize) {
         $pagess = floor($count / $pagesize) + 1;
     }
     $page = !empty($_GET['page']) ? $_GET['page'] : 1;
     if ($page <= 1) {
         $page = 1;
     }
     if ($page > $pagess) {
         $page = $pagess;
     }
     $page = $pagesize * ($page - 1);
     $limit = " limit {$page}, {$pagesize} ";
     $dealers = DbUtil::queryAll($sqldealer . $limit);
     $pageData = array('total_rows' => $count, 'parameter' => '', 'list_rows' => $pagesize, 'page_name' => 'page', 'ajax_func_name' => '', 'method' => '');
     $page = new Pagination($pageData);
     $page = $page->show(1);
     $this->render("search", array('search' => $search, 'dealers' => $dealers, 'count' => $count, 'page' => $page, 'pagesize' => $pagesize));
 }
示例#25
0
文件: uploadimgjs.php 项目: zwq/unpei
<script>
    window.onload = function() {
        var fileClass = "<?php 
echo Commonmodel::getOrganID();
?>
";
//        setTimeout(function() {
        $("#file_upload").uploadify({
            'auto': true,
            'queueId': 'some_file+queue',
            'swf': Yii_theme_baseUrl + '/js/uploadify/uploadify.swf',
            'uploader': Yii_baseUrl + '/upload/uploadify',
            'buttonText': '上传商品图片',
            //  'width'     : 82,//flash宽 由于设置的背景图片的宽是60 高是22 所以这里和下面设置60 22
            'height': 25, //flash高
            'method': 'post',
//            'formData': {'fileClass': fileClass, 'role': identity},
            'formData': {'fileClass': fileClass, 'add': '0', 'role': 'second'},
            'fileTypeExts': '*.gif; *.jpg; *.png; *.jpeg',
            'queueSizeLimit': 5, //上传数量  
            'fileSizeLimit': '2MB', //上传文件的大小限制
            'onFallback': function() {
                $(".loadflash").show();
            },
            'onUploadStart': function(file) {
                if ($("#showimglist").find("li").length >= 5) {
                    alert('上传图片过多,请删除队列中超过的图片');
                    $('#file_upload').uploadify('stop');        // 停止上传
                    $('#file_upload').uploadify('cancel');    // 清空队列
                }
                var imgarr = new Array();
示例#26
0
文件: GoodsImport.php 项目: zwq/unpei
 function parse($excelfile, $template, $data = array())
 {
     try {
         //获取上传文件的文件名扩展名
         $extend = strtolower(strrchr($excelfile, '.'));
         $readerType = $extend == '.xlsx' ? 'Excel2007' : 'Excel5';
         $objReader = new PHPExcel();
         $objReader = PHPExcel_IOFactory::createReader($readerType);
         //use Excel5 for 5fromat ,use excel2007 for 2007 format
         $objPHPExcel = $objReader->load($excelfile);
         if (!$objPHPExcel) {
             $error = '加载Excel出错';
             return array('success' => false, 'error' => $error);
         }
         $objWorksheet = $objPHPExcel->getActiveSheet();
         //取得活动sheet
         if (!$objWorksheet) {
             $error = '加载Excel出错';
             return array('success' => false, 'error' => $error);
         }
         $title = $objWorksheet->getTitle();
         //取得sheet名称
         $highestRow = $objWorksheet->getHighestRow();
         //取得总行数
         $highestColumn = $objWorksheet->getHighestColumn();
         //取得总列数
         $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
         //总列数
         //执行结果
         $error = "";
         $first_row = array();
         for ($col = 0; $col < $highestColumnIndex; $col++) {
             $first_row[$col] = $objWorksheet->getCellByColumnAndRow($col, 1)->getValue();
             if ($first_row[$col] == '商品编号') {
                 $GoodsNO_col = $col;
             }
         }
         //验证表结构,表名称和字段列表
         if (!$this->validateExcel($template, $first_row)) {
             $error = "Excel内容与模板不符合";
             //$error = $first_row;
             return array('success' => false, 'error' => $error);
         }
         //生成插入语句的头部
         $sql_header = $this->generateSqlHeader($template, $first_row);
         if ($sql_header == "") {
             $error = "SQL语句头部生成失败";
             return array('success' => false, 'error' => $error);
         }
         //生成SQL语句
         $sql = $sql_header;
         $i = 0;
         $list = array();
         for ($row = 2; $row <= $highestRow; $row++) {
             //每行的第一列数据不能为空
             $first_value = $objWorksheet->getCellByColumnAndRow(0, $row)->getValue();
             $GoodsNO_value = $objWorksheet->getCellByColumnAndRow($GoodsNO_col, $row)->getValue();
             if (in_array($GoodsNO_value, $list)) {
                 $success = false;
                 $error = '导入的商品编号重复';
                 return array('success' => $success, 'error' => $error);
             }
             if (empty($first_value)) {
                 continue;
             }
             $data_new = array();
             $sql_data = '(';
             ////注意highestColumnIndex的列数索引从0开始
             for ($col = 0; $col < $highestColumnIndex; $col++) {
                 $data_new[$col] = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
                 if ($col == $GoodsNO_col) {
                     $criteria = new CDbCriteria();
                     $criteria->addCondition("GoodsNO = '{$data_new[$col]}'");
                     $criteria->addCondition("OrganID =" . Commonmodel::getOrganID());
                     $criteria->addCondition("ISdelete = 1");
                     // echo Commonmodel::getOrganID();exit;
                     $bool = DealerGoods::model()->find($criteria);
                     if (!empty($bool)) {
                         $success = false;
                         $error = '商品编号已存在';
                         return array('success' => $success, 'error' => $error);
                     }
                 }
                 //                     if($col==4){   //  大类
                 //                          $data_new[$col] = DealerBigparts::getBigpartsID( $data_new[$col]);
                 //                     }
                 //                     if($col==5){   // 子类
                 //                          $data_new[$col] = DealerSubparts::getSubpartsID($data_new[$col]);
                 //                     }
                 //                     if($col==6){   // 标准名称
                 //                          $data_new[$col] = DealerCpname::getCpNameID($data_new[$col]) ;
                 //                     }
                 $sql_data .= "'" . trim($data_new[$col]) . "',";
             }
             if ($template == "dealergoods") {
                 //
                 $sql_data .= "'" . $data['OrganID'] . "','" . $data['UserID'] . "','" . $data['CreateTime'] . "'";
             }
             $sql_data .= ")";
             //var_dump($sql_data);exit;
             //验证数据是否正确
             //$this->validateData($data_new[$col]);
             $sql .= $sql_data . ',';
             $list[$i] = $GoodsNO_value;
             $i++;
         }
         $sql = rtrim($sql, ",") . ";";
         //返回结果数据
         $success = false;
         if ($error == "" && $sql != "") {
             $success = true;
         }
     } catch (Exception $e) {
         $success = false;
         $error = '解析Excel出错' . $e->getMessage();
     }
     //echo $sql;exit;
     return array('success' => $success, 'error' => $error, 'sql' => $sql);
 }
示例#27
0
文件: addempdea.php 项目: zwq/unpei
            <?php 
echo $form->labelEx($model, '经营级别:', array('class' => 'label'));
?>
            <?php 
echo $form->dropDownList($model, 'grade', CHtml::listData($level, 'level', 'level'), array('class' => 'width118 select', 'empty' => '选择级别'));
?>
            <?php 
echo $form->error($model, 'grade', array('style' => 'color: red;'));
?>
        </p>
        <p class="form-row">
            <?php 
echo $form->labelEx($model, '授权品类:', array('class' => 'label'));
?>
            <?php 
$cate_data = MakeEmpowerCategory::model()->findAll("userID=:userID", array(":userID" => Commonmodel::getOrganID()));
$categray = CHtml::listData($cate_data, "id", "cateName");
?>
            <?php 
echo $form->dropDownList($model, 'category', $categray, array('class' => 'width118 select', 'empty' => '选择品类'));
echo $form->error($model, 'category', array('style' => 'color: red;'));
?>
        </p>
        <p class="form-row">
            <?php 
echo $form->labelEx($model, '授权品牌:', array('class' => 'label'));
?>
            <?php 
echo $form->dropDownList($model, 'brand', array('A' => 'A', 'B' => 'B', 'C' => 'C'), array('class' => 'width118 select', 'empty' => '选择级别'));
?>
            <?php 
示例#28
0
 public function actionGetType()
 {
     $type_data = MakeType::model()->findAll(array("condition" => "OrganID = " . Commonmodel::getOrganID()));
     //. " AND IsDefault = 0"
     foreach ($type_data as $key => $type) {
         $data[$key]['ID'] = $type->ID;
         $data[$key]['TypeName'] = $type->TypeName;
     }
     echo json_encode($data);
 }
示例#29
0
 public function actionEditcategory()
 {
     $organID = Commonmodel::getOrganID();
     $categoryid = intval($_GET['id']);
     $userID = Yii::app()->user->id;
     $model = MakeGoodsCategory::model()->find('name="' . $_POST['name'] . '" and organID=' . $organID . ' and id!=' . $categoryid);
     if ($model) {
         echo json_encode(array('msg' => 'nameexist'));
         exit;
     }
     unset($model);
     $model = MakeGoodsCategory::model()->findByPk($categoryid);
     $model->attributes = $_POST;
     $model->userID = $userID;
     $model->updatetime = time();
     if ($model->save()) {
         echo json_encode(array('msg' => 'ok'));
     } else {
         echo json_encode(array('msg' => 'fail'));
     }
 }
示例#30
0
文件: DealerGoods.php 项目: zwq/unpei
 private static function getBrandByID($brand)
 {
     $organID = Commonmodel::getOrganID();
     if (!$brand) {
         return '';
     }
     $sql = "SELECT BrandName FROM `tbl_dealer_brand` WHERE ID = {$brand} and OrganID = {$organID}";
     $brands = DBUtil::query($sql);
     if ($brands) {
         return $brands['BrandName'];
     } else {
         return '';
     }
 }