Example #1
0
 /**
  * (non-PHPdoc)
  * @see CRUDPageAbstract::_getEndJs()
  */
 protected function _getEndJs()
 {
     $manufactureArray = $supplierArray = $statuses = $productCategoryArray = array();
     foreach (Manufacturer::getAll() as $os) {
         $manufactureArray[] = $os->getJson();
     }
     foreach (Supplier::getAll() as $os) {
         $supplierArray[] = $os->getJson();
     }
     foreach (ProductStatus::getAll() as $os) {
         $statuses[] = $os->getJson();
     }
     foreach (ProductCategory::getAll() as $os) {
         $productCategoryArray[] = $os->getJson();
     }
     $js = parent::_getEndJs();
     if (($product = Product::get($this->Request['id'])) instanceof Product) {
         $js .= "\$('searchPanel').hide();";
         $js .= "pageJs._singleProduct = true;";
     }
     $js .= 'pageJs._loadManufactures(' . json_encode($manufactureArray) . ')';
     $js .= '._loadSuppliers(' . json_encode($supplierArray) . ')';
     $js .= '._loadCategories(' . json_encode($productCategoryArray) . ')';
     $js .= '._loadProductStatuses(' . json_encode($statuses) . ')';
     $js .= "._loadChosen()";
     $js .= "._bindSearchKey()";
     $js .= ".setCallbackId('priceMatching', '" . $this->priceMatchingBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('toggleActive', '" . $this->toggleActiveBtn->getUniqueID() . "')";
     $js .= ".getResults(true, " . $this->pageSize . ");";
     return $js;
 }
 public function run()
 {
     $faker = Faker::create();
     $descriptions = ['okay', 'not okay', 'maybe'];
     foreach (range(1, 3) as $index) {
         ProductStatus::create(['description' => $descriptions[$index - 1]]);
     }
 }
Example #3
0
function updateProduct($pro, $fileName, $line)
{
    $clientScript = CatelogConnector::getConnector(B2BConnector::CONNECTOR_TYPE_CATELOG, getWSDL(), 'B2BUser', 'B2BUser');
    try {
        $transStarted = false;
        try {
            Dao::beginTransaction();
        } catch (Exception $e) {
            $transStarted = true;
        }
        $sku = trim($pro['sku']);
        $product = Product::getBySku($pro['sku']);
        $mageId = trim($pro['product_id']);
        $name = trim($pro['name']);
        $short_description = trim($pro['short_description']);
        $description = trim($pro['description']);
        $weight = trim($pro['weight']);
        $statusId = trim($pro['status']);
        $price = trim($pro['price']);
        $specialPrice = trim($pro['special_price']);
        $specialPrice_From = trim($pro['special_from_date']) === '' ? trim($pro['special_from_date']) : null;
        $specialPrice_To = trim($pro['special_to_date']) === '' ? trim($pro['special_to_date']) : null;
        $supplierName = trim($pro['supplier']);
        $attributeSet = ProductAttributeSet::get(trim($pro['attributeSetId']));
        if (!$product instanceof Product) {
            $product = Product::create($sku, $name);
        }
        $asset = ($assetId = trim($product->getFullDescAssetId())) === '' || !($asset = Asset::getAsset($assetId)) instanceof Asset ? Asset::registerAsset('full_desc_' . $sku, $description, Asset::TYPE_PRODUCT_DEC) : $asset;
        $product->setName($name)->setMageId($mageId)->setAttributeSet($attributeSet)->setShortDescription($short_description)->setFullDescAssetId(trim($asset->getAssetId()))->setIsFromB2B(true)->setStatus(ProductStatus::get($statusId))->setSellOnWeb(true)->setManufacturer($clientScript->getManufacturerName(trim($pro['manufacturer'])))->save()->clearAllPrice()->addPrice(ProductPriceType::get(ProductPriceType::ID_RRP), $price)->addInfo(ProductInfoType::ID_WEIGHT, $weight);
        if ($specialPrice !== '') {
            $product->addPrice(ProductPriceType::get(ProductPriceType::ID_CASUAL_SPECIAL), $specialPrice, $specialPrice_From, $specialPrice_To);
        }
        if ($supplierName !== '') {
            $product->addSupplier(Supplier::create($supplierName, $supplierName, true));
        }
        if (isset($pro['categories']) && count($pro['categories']) > 0) {
            $product->clearAllCategory();
            foreach ($pro['categories'] as $cateMageId) {
                if (!($category = ProductCategory::getByMageId($cateMageId)) instanceof ProductCategory) {
                    continue;
                }
                $product->addCategory($category);
            }
        }
        if ($transStarted === false) {
            Dao::commitTransaction();
        }
        //TODO remove the file
        removeLineFromFile($fileName, $line);
        echo $product->getId() . " => done! \n";
    } catch (Exception $ex) {
        if ($transStarted === false) {
            Dao::rollbackTransaction();
        }
        throw $ex;
    }
}
 /**
  * Show the form for creating a new product
  *
  * @return Response
  */
 public function create()
 {
     $product_brand_types = ProductBrandType::all();
     $product_brand_types_array = [];
     foreach ($product_brand_types as $product_brand_type) {
         $product_brand_types_array[$product_brand_type->id] = $product_brand_type->name;
     }
     $product_statuses = ProductStatus::all();
     $product_statuses_array = [];
     foreach ($product_statuses as $product_status) {
         $product_statuses_array[$product_status->id] = $product_status->description;
     }
     return View::make('products.create', array('product_brand_types' => $product_brand_types_array, 'product_statuses' => $product_statuses_array));
 }
Example #5
0
 /**
  * (non-PHPdoc)
  * @see CRUDPageAbstract::_getEndJs()
  */
 protected function _getEndJs()
 {
     $manufactureArray = $supplierArray = $statuses = $productCategoryArray = array();
     foreach (Manufacturer::getAll() as $os) {
         $manufactureArray[] = $os->getJson();
     }
     foreach (Supplier::getAll() as $os) {
         $supplierArray[] = $os->getJson();
     }
     foreach (ProductStatus::getAll() as $os) {
         $statuses[] = $os->getJson();
     }
     foreach (ProductCategory::getAll() as $os) {
         $productCategoryArray[] = $os->getJson();
     }
     $js = parent::_getEndJs();
     if (($product = Product::get($this->Request['id'])) instanceof Product) {
         $js .= "\$('searchPanel').hide();";
         $js .= "pageJs._singleProduct = true;";
     }
     $js .= 'pageJs.totalValueId = "total-found-value";';
     $js .= 'pageJs.totalQtyId = "total-found-qty";';
     $js .= 'pageJs._loadManufactures(' . json_encode($manufactureArray) . ')';
     $js .= '._loadSuppliers(' . json_encode($supplierArray) . ')';
     $js .= '._loadCategories(' . json_encode($productCategoryArray) . ')';
     $js .= '._loadProductStatuses(' . json_encode($statuses) . ')';
     $js .= "._loadChosen()";
     $js .= "._bindSearchKey()";
     $js .= "._bindNewRuleBtn()";
     $js .= ".setCallbackId('priceMatching', '" . $this->priceMatchingBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('toggleActive', '" . $this->toggleActiveBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('toggleSellOnWeb', '" . $this->toggleSellOnWebBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('updatePrice', '" . $this->updatePriceBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('updateStockLevel', '" . $this->updateStockLevelBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('toggleIsKit', '" . $this->toggleIsKitBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('toggleManualFeed', '" . $this->toggleManualFeedBtn->getUniqueID() . "')";
     $js .= ".setCallbackId('newRule', '" . $this->newRuleBtn->getUniqueID() . "')";
     $js .= ".getResults(true, " . $this->pageSize . ");";
     return $js;
 }
Example #6
0
 public function view_modifyOrderList()
 {
     global $memc_obj;
     $sysUserId = $_SESSION['sysUserId'];
     $modify_showerrorinfo = '';
     $OrderModifyAct = new OrderModifyAct();
     $OrderindexAct = new OrderindexAct();
     $UserCompetenceAct = new UserCompetenceAct();
     //var_dump($_GET); exit;
     if (isset($_GET) && !empty($_GET)) {
         $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
         $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
         $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
     }
     if (isset($_POST) && !empty($_POST)) {
         //var_dump($_POST); echo "<br>"; exit;
         $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : '';
         $ostatus = isset($_POST['edit_ostatus']) ? $_POST['edit_ostatus'] : $_POST['ostatus'];
         $otype = isset($_POST['edit_otype']) ? $_POST['edit_otype'] : $_POST['otype'];
         $update_order = array();
         $update_userinfo = array();
         $update_tracknumber = array();
         //$orderid = $_POST['orderid'];
         //var_dump($_POST); exit;
         $updatestatus = false;
         if ($_POST['action'] == 'addDetail') {
             //var_dump($_GET); echo "<br>"; exit;
             $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
             $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
             $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
             if ($OrderModifyAct->act_batchAdd($orderid, $_POST)) {
                 $modify_showerrorinfo = "<font color='green'>添加成功</font>";
             } else {
                 $modify_showerrorinfo = "<font color='red'>添加失败</font>";
             }
         } else {
             if ($_POST['action'] == 'addNote') {
                 //var_dump($_GET); echo "<br>"; exit;
                 $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
                 $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
                 $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
                 if ($OrderModifyAct->act_addNote($orderid, $_POST)) {
                     $modify_showerrorinfo = "<font color='green'>添加成功</font>";
                 } else {
                     $modify_showerrorinfo = "<font color='red'>添加失败</font>";
                 }
             } else {
                 $visible_movefolder = $UserCompetenceAct->act_getInStatusIds($_POST['otype'], $sysUserId);
                 if (!in_array($_POST['edit_otype'], $visible_movefolder)) {
                     $modify_showerrorinfo = "<font color='red'>您没有改变订单状态的权限</font>";
                 } else {
                     if ($_POST['username'] != $_POST['edit_username']) {
                         $update_userinfo['username'] = $_POST['edit_username'];
                     }
                     if ($_POST['ostatus'] != $_POST['edit_ostatus']) {
                         $update_order['orderStatus'] = $_POST['edit_ostatus'];
                     }
                     if ($_POST['otype'] != $_POST['edit_otype']) {
                         $update_order['orderType'] = $_POST['edit_otype'];
                         $updatestatus = true;
                     }
                     if ($_POST['street'] != $_POST['edit_street']) {
                         $update_userinfo['street'] = $_POST['edit_street'];
                     }
                     if ($_POST['platformUsername'] != $_POST['edit_platformUsername']) {
                         $update_userinfo['platformUsername'] = $_POST['edit_platformUsername'];
                     }
                     if ($_POST['address2'] != $_POST['edit_address2']) {
                         $update_userinfo['address2'] = $_POST['edit_address2'];
                     }
                     if ($_POST['actualShipping'] != $_POST['edit_actualShipping']) {
                         $update_order['actualShipping'] = $_POST['edit_actualShipping'];
                     }
                     if ($_POST['city'] != $_POST['edit_city']) {
                         $update_userinfo['city'] = $_POST['edit_city'];
                     }
                     if ($_POST['state'] != $_POST['edit_state']) {
                         $update_userinfo['state'] = $_POST['edit_state'];
                     }
                     if ($_POST['countryName'] != $_POST['edit_countryName']) {
                         $update_userinfo['countryName'] = $_POST['edit_countryName'];
                     }
                     if ($_POST['zipCode'] != $_POST['edit_zipCode']) {
                         $update_userinfo['zipCode'] = $_POST['edit_zipCode'];
                     }
                     if ($_POST['landline'] != $_POST['edit_landline']) {
                         $update_userinfo['landline'] = $_POST['edit_landline'];
                     }
                     if ($_POST['phone'] != $_POST['edit_phone']) {
                         $update_userinfo['phone'] = $_POST['edit_phone'];
                     }
                     if ($_POST['transportId'] != $_POST['edit_transportId']) {
                         $update_order['transportId'] = $_POST['edit_transportId'];
                     }
                     if ($_POST['edit_tracknumber']) {
                         $update_tracknumber['omOrderId'] = $orderid;
                         $update_tracknumber['tracknumber'] = $_POST['edit_tracknumber'];
                         $update_tracknumber['addUser'] = $sysUserId;
                         $update_tracknumber['createdTime'] = time();
                         //var_dump($update_tracknumber); exit;
                     }
                     BaseModel::begin();
                     //开始事务
                     if ($update_order) {
                         //$sql = "UPDATE om_unshipped_order set ".array2sql($update_order)." WHERE id = ".$orderid;
                         //$msg = OrderLogModel::orderLog($orderid,$update_order['orderStatus'],$update_order['orderType'],$sql);
                         if (OrderindexModel::updateOrder('om_unshipped_order', $update_order, ' WHERE id = ' . $orderid)) {
                             if ($updatestatus) {
                                 $ProductStatus = new ProductStatus();
                                 if (!$ProductStatus->updateSkuStatusByOrderStatus(array($orderid), $batch_ostatus_val, $batch_otype_val)) {
                                     BaseModel::rollback();
                                 }
                             }
                             $modify_showerrorinfo = "<font color='green'>更新成功</font>";
                         } else {
                             $modify_showerrorinfo = "<font color='red'>更新失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     if ($update_userinfo) {
                         //var_dump($update_userinfo);
                         if (OrderindexModel::updateOrder('om_unshipped_order_userInfo', $update_userinfo, ' WHERE omOrderId = ' . $orderid)) {
                             $modify_showerrorinfo = "<font color='green'>更新成功</font>";
                         } else {
                             $modify_showerrorinfo = "<font color='red'>更新失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     if ($update_tracknumber) {
                         //echo $msg;
                         if (!OrderAddModel::insertOrderTrackRow($update_tracknumber)) {
                             /*self :: $errCode = "001";
                             		self :: $errMsg =  "跟踪号插入失败";
                             		return false;*/
                             $modify_showerrorinfo = "<font color='red'>跟踪号插入失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     BaseModel::commit();
                     BaseModel::autoCommit();
                 }
             }
         }
     }
     $this->smarty->assign('modify_showerrorinfo', $modify_showerrorinfo);
     $omAvailableAct = new OmAvailableAct();
     //平台信息
     $platform = $omAvailableAct->act_getTNameList('om_platform', 'id,platform', 'WHERE is_delete=0');
     //var_dump($platform);
     $platformList = array();
     foreach ($platform as $v) {
         $platformList[$v['id']] = $v['platform'];
     }
     $this->smarty->assign('platformList', $platformList);
     /**导航 start**/
     $this->smarty->assign('ostatus', $ostatus);
     $this->smarty->assign('otype', $otype);
     //二级目录
     $StatusMenuAct = new StatusMenuAct();
     $ostatusList = $StatusMenuAct->act_getStatusMenuList('statusCode,statusName', 'WHERE groupId = 0 AND is_delete=0');
     //var_dump($ostatusList);
     $this->smarty->assign('ostatusList', $ostatusList);
     $otypeList = $StatusMenuAct->act_getStatusMenuList('statusCode,statusName', 'WHERE groupId = "' . $ostatus . '" AND is_delete=0');
     //var_dump($otypeList);
     $this->smarty->assign('otypeList', $otypeList);
     /*$o_secondlevel =  $omAvailableAct->act_getTNameList('om_status_menu','*','WHERE is_delete=0 and groupId=0 order by sort asc');
     		$this->smarty->assign('o_secondlevel', $o_secondlevel);*/
     $second_count = array();
     $second_type = array();
     foreach ($ostatusList as $o_secondinfo) {
         $orderStatus = $o_secondinfo['statusCode'];
         /*$accountacc = $_SESSION['accountacc'];
         		$oc_where = " where orderStatus='$orderStatus' ";
         		if($accountacc){
         			$oc_where .= ' AND ('.$accountacc.') ';
         		}*/
         $s_total = $OrderindexAct->act_showSearchOrderNum($orderStatus);
         //$s_total = $omAvailableAct->act_getTNameCount("om_unshipped_order", $oc_where);
         $second_count[$o_secondinfo['statusCode']] = $s_total;
         $s_type = $omAvailableAct->act_getTNameList("om_status_menu", "*", "WHERE is_delete=0 and groupId='{$orderStatus}' order by sort asc");
         $second_type[$o_secondinfo['statusCode']] = $s_type[0]['statusCode'];
     }
     //var_dump($second_count);
     $this->smarty->assign('second_count', $second_count);
     $this->smarty->assign('second_type', $second_type);
     //退款数量
     $refund_total = $omAvailableAct->act_getTNameCount("om_order_refund", " where is_delete=0");
     $this->smarty->assign('refund_total', $refund_total);
     //三级目录
     $o_threelevel = $omAvailableAct->act_getTNameList("om_status_menu", "*", "WHERE is_delete=0 and groupId='{$ostatus}' order by sort asc");
     $this->smarty->assign('o_threelevel', $o_threelevel);
     $three_count = array();
     foreach ($o_threelevel as $o_threeinfo) {
         $orderType = $o_threeinfo['statusCode'];
         $s_total = $OrderindexAct->act_showSearchOrderNum($ostatus, $orderType);
         //$s_total = $omAvailableAct->act_getTNameCount("om_unshipped_order"," where orderStatus='$ostatus' and orderType='$orderType' and storeId=1 and is_delete=0");
         $three_count[$o_threeinfo['statusCode']] = $s_total;
     }
     $this->smarty->assign('three_count', $three_count);
     $toptitle = '订单显示页面';
     //头部title
     $this->smarty->assign('toptitle', $toptitle);
     $this->smarty->assign('toplevel', 0);
     $threelevel = '1';
     //当前的三级菜单
     $this->smarty->assign('threelevel', $threelevel);
     $statusMenu = $omAvailableAct->act_getTNameList('om_status_menu', ' * ', 'WHERE is_delete=0 ');
     $this->smarty->assign('statusMenu', $statusMenu);
     $value = '';
     $where = '';
     switch ($searchTransportationType) {
         case '1':
             $transportation = CommonModel::getCarrierList(1);
             //快递
             break;
         case '2':
             $transportation = CommonModel::getCarrierList(0);
             //平邮
             break;
         default:
             $transportation = CommonModel::getCarrierList();
             //所有的
             break;
     }
     //var_dump($transportation); exit;
     $transportationList = array();
     foreach ($transportation as $tranValue) {
         $transportationList[$tranValue['id']] = $tranValue['carrierNameCn'];
     }
     //var_dump($transportationList); exit;
     $this->smarty->assign('transportation', $transportation);
     $this->smarty->assign('transportationList', $transportationList);
     //var_dump($orderid, $ostatus,$otype);
     $omOrderList = $OrderModifyAct->act_getModifyOrderList($orderid, $ostatus, $otype, $storeId = 1);
     //var_dump($omOrderList);
     //$sku	=	array();
     $account_where = ' WHERE is_delete = 0 ';
     if ($searchPlatformId) {
         $account_where .= ' AND platformId = ' . $searchPlatformId;
     }
     $accountList = $UserCompetenceAct->act_showGlobalUser();
     if ($accountList) {
         $account_where .= ' AND id in ( ' . join(',', $accountList) . ' ) ';
     }
     //帐号信息
     $accountList = $omAvailableAct->act_getTNameList('om_account', '*', $account_where);
     //var_dump($accountList); exit;
     $account = array();
     foreach ($accountList as $v) {
         $account[$v['id']] = $v['account'];
     }
     //包材信息
     $pm = GoodsModel::getMaterInfoByList();
     //获取系统所有状态
     $statusList = copyOrderModel::selectStatusList();
     $CurrencyAct = new CurrencyAct();
     $currencyList = $CurrencyAct->act_getCurrencyListById();
     //echo "<pre>"; print_r($currencyList); exit;
     $this->smarty->assign('currencyList', $currencyList);
     $this->smarty->assign('statusList', $statusList);
     $this->smarty->assign('show_page', $show_page);
     $this->smarty->assign('account', $account);
     $this->smarty->assign('accountList', $accountList);
     $this->smarty->assign('pm', $pm);
     $this->smarty->assign('omOrderList', $omOrderList);
     $this->smarty->display('orderModify.htm');
 }
 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     require_once 'modules/Quotes/Quote.php';
     require_once 'modules/QuoteLines/QuoteLine.php';
     require_once 'log4php/LoggerManager.php';
     require_once 'include/formbase.php';
     require_once 'include/TimeDate.php';
     $timedate = new TimeDate();
     $focus = new Quote();
     if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     $focus = populateFromPost($prefix, $focus);
     if (!ACLController::checkAccess($focus->module_dir, 'edit', $focus->isOwner($current_user->id))) {
         ACLController::displayNoAccess(true);
     }
     ///// Retrive old status ///////
     $old_bean = new Products();
     $old_bean->retrieve($focus->product_id);
     $old_status = $old_bean->status;
     //////////////////////////////
     /*	if(empty($_REQUEST['status']) || $_REQUEST['status'] == 'off'){
     		$focus->status = 0;	
     	}else{
     		$focus->status= 1;
     	}
     	
     	echo "post length:".count($_POST); 
         echo "product_count:".$count."<br>";
     	echo "cost_price num:".count($_POST["cost_price"])."<br";*/
     $return_id = $focus->save();
     /*$quoteLine1 = new QuoteLine();
     	$quoteLine1->mark_deletedByQuoteid($return_id);
     	$count = count($_POST);
     	$keys = array_keys($_POST);
     	$sum = 0;
     	for($i = 0;$i< $count; $i++) {
     		//echo $keys[$i]."<br>";
     		if(substr_count($keys[$i],"productid_") > 0) {
     			$index = substr($keys[$i],strpos($keys[$i],"_")+1);
     			$product_id = $_POST["productid_".$index];
     			
     			if(!isset($product_id) || empty($product_id))
     				continue;
     			
     			$product_name = $_POST["productname_".$index];
     			$product_num = $_POST["productnum_".$index];
                 $pages = $_POST["pages_".$index];
      			$quantity = $_POST["quantity_".$index];
                 $estp = $_POST["estp_".$index];
                 $price = $_POST["price_".$index];     
                 
     			$quoteLine = new QuoteLine();
                 $quoteLine->price = $price;
                 $quoteLine->estp = $estp;
                 $quoteLine->productid = $product_id;
                 $quoteLine->productname = $product_name;
                 $quoteLine->productnum = $product_num;
                 $quoteLine->pages = $pages;
     			$quoteLine->quantity = $quantity;
     			$quoteLine->quoteid = $return_id;
     			$quoteLine->save();
     		}
     	}
     	$count = $_POST["product_count"];*/
     /*	$component = new ProductComponents;
     	$component->retrieve($sugarbean->component_id);
     	$component->status_update('quoted', $component->id);*/
     //	$GLOBLES['log']->debug("Saved record with id of ".$return_id);
     if ($redirect) {
         $this->handleRedirect($return_id);
     } else {
         return $focus;
     }
     $productstatus = new ProductStatus();
     if (isset($_REQUEST['status_action']) && !empty($_REQUEST['status_action'])) {
         $productstatus->update_product_status($_REQUEST['status_action'], $focus, $old_status);
     } else {
         $productstatus->update_product_status($_REQUEST['status'], $focus, $old_status);
     }
 }
Example #8
0
if (!isset($sugarbean->product_id) || is_null($sugarbean->product_id) || empty($sugarbean->product_id)) {
    $product = new Products();
    $product->account_id = $_REQUEST['account_id'];
    $product->account_name = $_REQUEST['account_name'];
    $product->contact_id = $_REQUEST['contact_id'];
    $product->contact_name = $_REQUEST['contact_name'];
    $product->name = $_REQUEST['product_name'];
    $product->number = 'PRD' . $product->generate_number('number', $product->table_name);
    //TO DO GENERATE NUMBER
    $product->save($GLOBALS['check_notify']);
    $sugarbean->product_id = $product->id;
} else {
    $product = new Products();
    $product->retrieve($sugarbean->product_id);
}
$sugarbean->save($GLOBALS['check_notify']);
$product->clientorder_id = $sugarbean->id;
$product->save($GLOBALS['check_notify']);
$sugarbean->save($GLOBALS['check_notify']);
if (isset($_REQUEST['add_component']) && $_REQUEST['add_component'] != "") {
    $_REQUEST['return_url'] = 'index.php?module=EstimateComponents&action=EditView&return_module=' . $_REQUEST['parent_bean'] . '&add_component=true&return_id=' . $sugarbean->id . '&return_action=EditView&parent_id=' . $sugarbean->id . '&parent_name=' . $sugarbean->name . '&parent_bean=' . $_REQUEST['parent_bean'];
}
//$sugarbean->status_update('',$sugarbean->id);
$return_id = $sugarbean->id;
$productstatus = new ProductStatus();
if (isset($_REQUEST['status_action']) && !empty($_REQUEST['status_action'])) {
    $productstatus->update_product_status($_REQUEST['status_action'], $sugarbean, $old_status);
} else {
    $productstatus->update_product_status($_REQUEST['status'], $sugarbean, $old_status);
}
handleRedirect($return_id, 'ClientOrders');
Example #9
0
<?php

include_once __DIR__ . '/../framework.php';
// 加载框架
Core::getInstance();
// 初始化框架对象
include_once __DIR__ . '/../lib/productstatus.class.php';
// 加载框架
error_reporting(-1);
$product = new ProductStatus();
global $dbConn;
$updateSkuArr = array();
if (isset($argv[2])) {
    // 更新单个采购的料号
    $sql = "select a.sku from pc_goods as a left join power_global_user as b on a.purchaseId=b.global_user_id where b.global_user_name='{$argv[2]}' ";
    echo $sql;
    $sql = $dbConn->execute($sql);
    $skuArr = $dbConn->getResultArray($sql);
    foreach ($skuArr as $item) {
        $updateSkuArr[] = $item['sku'];
    }
}
//$updateSkuArr = array("1724");
foreach ($updateSkuArr as $sku) {
    //$product->resetSkuStock($sku,1);
    //$product->calcAverageDailyCount($item['sku']);
    $product->resetSkuAverage($sku);
}
if (isset($argv[2])) {
    $sku = $argv[2];
    $product->resetSkuStock($sku, 1);
Example #10
0
 /**
  * 插入订单对应下的总表信息,没有批量处理事件
  * @para $data as array
  * @add by Herman.Xi
  * @last modified 20131022
  * $in 默认为进入订单模式
  */
 public static function insertAllOrderRowNoEvent($orderData, $tName = 'om_unshipped_order', $in = true)
 {
     self::initDB();
     //var_dump($orderData); exit;
     $obj_order_data = $orderData['orderData'];
     $orderExtenData = $orderData['orderExtenData'];
     $orderUserInfoData = $orderData['orderUserInfoData'];
     $orderDetailArr = $orderData['orderDetail'];
     $orderTrackInfo = $orderData['orderTrack'];
     //var_dump($obj_order_data); exit;
     //$tName = 'om_unshipped_order';
     $where = "WHERE recordNumber='{$obj_order_data['recordNumber']}' AND platformId={$obj_order_data['platformId']}";
     $flagCountUnshipped = OmAvailableModel::getTNameCount($tName, $where);
     //var_dump($flagCountUnshipped); exit;
     $_tName = 'om_shipped_order';
     $flagCountshipped = OmAvailableModel::getTNameCount($_tName, $where);
     if ($obj_order_data && empty($flagCountshipped)) {
         //判断订单是否已经在系统2个订单表(未发货和已发货)中存在
         $platfrom = omAccountModel::getPlatformSuffixById($obj_order_data['platformId']);
         $extension = $platfrom['suffix'];
         //获取后缀名称
         //echo $extension; echo "<br>"; exit;
         $insertOrderDataRow = self::insertOrderRow($obj_order_data, $tName);
         //插入到order表
         if (empty($insertOrderDataRow)) {
             self::$errCode = "020";
             self::$errMsg = "插入订单失败!";
             return false;
         }
         $orderExtenData['omOrderId'] = $insertOrderDataRow;
         $orderUserInfoData['omOrderId'] = $insertOrderDataRow;
         $resultExten = self::insertExtension($orderExtenData, $extension, $tName);
         //插入到order_extend表
         if (!$resultExten) {
             self::$errCode = "021";
             self::$errMsg = "插入订单附加表失败!";
             return false;
         }
         $resultUserInfo = self::insertUserinfoRow($orderUserInfoData, $tName);
         //插入到order_userInfo表
         if (!$resultUserInfo) {
             self::$errCode = "022";
             self::$errMsg = "插入用户信息表失败!";
             return false;
         }
         foreach ($orderDetailArr as $orderDetail) {
             $orderDetailData = $orderDetail['orderDetailData'];
             $orderDetailExtenData = $orderDetail['orderDetailExtenData'];
             $orderDetailData['omOrderId'] = $insertOrderDataRow;
             $orderDetailData['createdTime'] = time();
             $insertOrderDatilRow = self::insertOrderdetail($orderDetailData, $tName);
             //插入到detail表
             if (empty($insertOrderDatilRow)) {
                 self::$errCode = "023";
                 self::$errMsg = "插入订明细单失败!";
                 return false;
             }
             $orderDetailExtenData['omOrderdetailId'] = $insertOrderDatilRow;
             if ($orderDetailExtenData) {
                 $resultOrderDetailExten = self::insertDetailExtension($orderDetailExtenData, $extension, $tName);
                 //插入到detailExtend
                 if (!$resultOrderDetailExten) {
                     self::$errCode = "024";
                     self::$errMsg = "插入订单明细附带表失败!";
                     return false;
                 }
             }
         }
         if ($obj_order_data['platformId'] == 1 && $in) {
             $insertOrderidsDada = array('omOrderId' => $insertOrderDataRow, 'PayPalPaymentId' => $orderData['orderExtenData']['PayPalPaymentId'], 'orderid' => $orderData['orderExtenData']['orderId'], 'accountId' => $orderData['orderData']['accountId'], 'saletime' => time());
             $insertOrderids = OrderidsModel::insertOrderidsList($insertOrderidsDada);
             if (!$insertOrderids) {
                 self::$errCode = "025";
                 self::$errMsg = "插入ebay订单IDS失败!";
                 return false;
             }
         }
         if (isset($orderData['orderNote']) && !empty($orderData['orderNote'])) {
             $orderNote = $orderData['orderNote'];
             $insertOrderNoteDada = array('omOrderId' => $insertOrderDataRow, 'content' => $orderNote['content'], 'userId' => $orderNote['userId'], 'createdTime' => $orderNote['createdTime']);
             $insertOrderNoteids = self::insertOrderNotesRow($insertOrderNoteDada);
             if (!$insertOrderNoteids) {
                 self::$errCode = "026";
                 self::$errMsg = "插入订单Note失败!";
                 return false;
             }
         }
         $buyerInfo = $orderUserInfoData;
         $buyerInfo['platformId'] = $obj_order_data['platformId'];
         unset($buyerInfo['omOrderId']);
         unset($buyerInfo['countrySn']);
         unset($buyerInfo['currency']);
         unset($buyerInfo['currency']);
         //var_dump($buyerInfo);
         $insertBuyerInfo = self::insertBuyerInfoRow($buyerInfo);
         //var_dump($insertBuyerInfo);
         if (!$insertBuyerInfo) {
             return false;
         }
         //判断为新插入订单时,需要插入跟踪号
         if ($orderTrackInfo['tracknumber'] != '' && $in) {
             $orderTrackInfo['omOrderId'] = $insertOrderDataRow;
             $insertTrack = self::insertOrderTrackRow($orderTrackInfo);
             if (!$insertTrack) {
                 return false;
             }
         }
         $ProductStatus = new ProductStatus();
         if (!$ProductStatus->updateSkuStatusByOrderStatus(array($insertOrderDataRow))) {
             self::$errCode = "400";
             self::$errMsg = "已经包含订单信息,不能重复插入!";
             return false;
         }
         //var_dump($insertOrderDataRow); exit;
         return $insertOrderDataRow;
     } else {
         self::$errCode = "400";
         self::$errMsg = "已经包含订单信息,不能重复插入!";
         return false;
     }
 }
Example #11
0
<?php

include_once __DIR__ . '/../framework.php';
// 加载框架
Core::getInstance();
// 初始化框架对象
include_once __DIR__ . '/../lib/productstatus.class.php';
// 加载框架
error_reporting(-1);
$product = new ProductStatus();
//$product->updateSkuStatusByOrderStatus(21,201);
global $dbConn;
$sql = "SELECT sku,spu FROM `pc_goods` where 1";
$sql = $dbConn->execute($sql);
$skuInfo = $dbConn->getResultArray($sql);
foreach ($skuInfo as $item) {
    //$product->checkDailyStatus($item['sku'],$item['spu']);
    $sku = $item['sku'];
    //$num = $product->getPastDayCount("18845_BL_M",30);
    //$dayilyNum = $product->calcAverageDailyCount($item['sku']);
    //$sql = "UPDATE `om_sku_daily_status` set AverageDailyCount={$dayilyNum} where sku='{$sku}'";
    //resetSkuStock
    /*
    	if($dbConn->execute($sql)){
    		echo "均量更新成功。。。。\n";
    	}
    */
    $product->resetSkuStock($item['sku'], 1);
}
Example #12
0
 public function act_modifyOrder()
 {
     if (isset($_POST) && !empty($_POST)) {
         //$OrderModifyAct->act_modifyOrder();
         $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : '';
         $ostatus = isset($_POST['edit_ostatus']) ? $_POST['edit_ostatus'] : $_POST['ostatus'];
         $otype = isset($_POST['edit_otype']) ? $_POST['edit_otype'] : $_POST['otype'];
         $update_order = array();
         $update_userinfo = array();
         $update_tracknumber = array();
         //$orderid = $_POST['orderid'];
         //var_dump($_POST); exit;
         $updatestatus = false;
         if (!empty($_POST['data'])) {
             $data = $_POST['data'];
         }
         if (isset($data['username'])) {
             $update_userinfo['username'] = $data['username'];
         }
         if (isset($data['orderStatus'])) {
             $update_order['orderStatus'] = $data['orderStatus'];
         }
         if (isset($data['orderType'])) {
             $update_order['orderType'] = $data['orderType'];
             $updatestatus = true;
         }
         if (isset($data['street'])) {
             $update_userinfo['street'] = $data['street'];
         }
         if (isset($data['platformUsername'])) {
             $update_userinfo['platformUsername'] = $data['platformUsername'];
         }
         if (isset($data['address2'])) {
             $update_userinfo['address2'] = $data['address2'];
         }
         if (isset($data['actualShipping'])) {
             $update_order['actualShipping'] = $data['actualShipping'];
         }
         if (isset($data['city'])) {
             $update_userinfo['city'] = $data['city'];
         }
         if (isset($data['state'])) {
             $update_userinfo['state'] = $data['state'];
         }
         if (isset($data['countryName'])) {
             $update_userinfo['countryName'] = $data['countryName'];
         }
         if (isset($data['zipCode'])) {
             $update_userinfo['zipCode'] = $data['zipCode'];
         }
         if (isset($data['landline'])) {
             $update_userinfo['landline'] = $data['landline'];
         }
         if (isset($data['phone'])) {
             $update_userinfo['phone'] = $data['phone'];
         }
         if (isset($data['transportId'])) {
             $update_order['transportId'] = $data['transportId'];
         }
         if (isset($data['update_notes'])) {
             $update_note = $data['update_notes'];
         }
         if (isset($data['note_new'])) {
             $add_note = $data['note_new'];
         }
         if ($data['edit_tracknumber']) {
             $update_tracknumber['omOrderId'] = $orderid;
             $update_tracknumber['tracknumber'] = $data['edit_tracknumber'];
             $update_tracknumber['addUser'] = $_SESSION['sysUserId'];
             $update_tracknumber['createdTime'] = time();
             //var_dump($update_tracknumber); exit;
         }
         BaseModel::begin();
         //开始事务
         if ($update_order) {
             //$sql = "UPDATE om_unshipped_order set ".array2sql($update_order)." WHERE id = ".$orderid;
             //$msg = commonModel::orderLog($orderid,$update_order['orderStatus'],$update_order['orderType'],$sql);
             if (OrderindexModel::updateOrder('om_unshipped_order', $update_order, ' WHERE id = ' . $orderid)) {
                 if ($updatestatus) {
                     $ProductStatus = new ProductStatus();
                     if (!$ProductStatus->updateSkuStatusByOrderStatus(array($orderid), $batch_ostatus_val, $batch_otype_val)) {
                         BaseModel::rollback();
                     }
                 }
                 $modify_showerrorinfo = "<font color='green'>更新成功</font>";
             } else {
                 self::$errCode = "001";
                 self::$errMsg = "更新订单信息失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_userinfo) {
             //var_dump($update_userinfo);
             if (OrderindexModel::updateOrder('om_unshipped_order_userInfo', $update_userinfo, ' WHERE omOrderId = ' . $orderid)) {
                 $modify_showerrorinfo = "<font color='green'>更新成功</font>";
             } else {
                 self::$errCode = "002";
                 self::$errMsg = "更新订单用户信息失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_tracknumber) {
             //echo $msg;
             if (!OrderAddModel::insertOrderTrackRow($update_tracknumber)) {
                 self::$errCode = "003";
                 self::$errMsg = "更新订单跟踪号插入失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_note) {
             foreach ($update_note as $key => $value) {
                 $notes = explode("###", $value);
                 $where = " where content='{$notes[0]}' and omOrderId={$orderid}";
                 $set = "set content='{$notes[1]}',userId={$_SESSION['sysUserId']},createdTime=" . time();
                 $msg = OmAvailableModel::updateTNameRow("om_order_notes", $set, $where);
                 if (!$msg) {
                     self::$errCode = "004";
                     self::$errMsg = "更新订单备注失败!";
                     BaseModel::rollback();
                     return false;
                 }
             }
         }
         if ($add_note) {
             foreach ($add_note as $key => $value) {
                 $set = "set omOrderId={$orderid},content='{$value}',userId={$_SESSION['sysUserId']},createdTime=" . time();
                 $msg = OmAvailableModel::insertRow("om_order_notes", $set);
                 if (!$msg) {
                     self::$errCode = "005";
                     self::$errMsg = "插入订单备注失败!";
                     BaseModel::rollback();
                     return false;
                 }
             }
         }
         self::$errCode = "200";
         self::$errMsg = "整个订单信息更新成功!";
         BaseModel::commit();
         BaseModel::autoCommit();
     }
 }
Example #13
0
 /**
  * import all products
  *
  * @return CatelogConnector
  */
 public function importProducts()
 {
     if (!($systemSetting = SystemSettings::getByType(SystemSettings::TYPE_LAST_NEW_PRODUCT_PULL)) instanceof SystemSettings) {
         throw new Exception('cannot get LAST_NEW_PRODUCT_PULL in system setting');
     }
     $fromDate = $systemSetting->getValue();
     $products = $this->getProductList($fromDate);
     if (count($products) === 0) {
         echo 'nothing from magento. exitting' . "\n";
         return $this;
     }
     try {
         $transStarted = false;
         try {
             Dao::beginTransaction();
         } catch (Exception $e) {
             $transStarted = true;
         }
         foreach ($products as $pro) {
             $mageId = trim($pro->product_id);
             $sku = trim($pro->sku);
             $pro = $this->getProductInfo($sku, $this->getInfoAttributes());
             $created_at = trim($pro->created_at);
             $updated_at = trim($pro->updated_at);
             $product_id = trim($pro->product_id);
             if (is_null($pro) || !isset($pro->additional_attributes)) {
                 continue;
             }
             // handle extra long sku from magento, exceeding mysql sku length limit
             DaoMap::loadMap('Product');
             $skuSizeLimit = DaoMap::$map['product']['sku']['size'];
             if (strlen($sku) > $skuSizeLimit) {
                 echo 'Product ' . $sku . '(id=' . $product->getId() . ', magento Product Creation Time=' . trim($pro->created_at) . ') magento sku length exceed system sku length limit of' . $skuSizeLimit . ', skipped' . "\n";
                 continue;
             }
             $additionAttrs = $this->_getAttributeFromAdditionAttr($pro->additional_attributes);
             $name = trim($additionAttrs['name']);
             $short_description = trim($additionAttrs['short_description']);
             $description = trim($additionAttrs['description']);
             $weight = trim($additionAttrs['weight']);
             $statusId = trim($additionAttrs['status']);
             $price = trim($additionAttrs['price']);
             $specialPrice = isset($additionAttrs['special_price']) ? trim($additionAttrs['special_price']) : '';
             $specialPrice_From = isset($additionAttrs['special_from_date']) ? trim($additionAttrs['special_from_date']) : null;
             $specialPrice_To = isset($additionAttrs['special_to_date']) ? trim($additionAttrs['special_to_date']) : null;
             if (!($product = Product::getBySku($sku)) instanceof Product) {
                 $product = Product::create($sku, $name);
                 Log::logging(0, get_class($this), 'Found New Product from Magento with sku="' . trim($sku) . '" and name="' . $name . '", created_at="' . $created_at, self::LOG_TYPE, '', __FUNCTION__);
                 echo 'Found New Product from Magento with sku="' . trim($sku) . '" and name="' . $name . '", created_at="' . $created_at . ', updated_at' . $updated_at . "\n";
             } elseif (Product::getBySku($sku) instanceof Product) {
                 $product = Product::getBySku($sku);
                 echo 'Found Existing Product from Magento with sku="' . trim($sku) . '" and name="' . $name . '", created_at="' . $created_at . ', updated_at' . $updated_at . '"' . "\n";
                 echo "\t" . 'Name: "' . $name . '"' . "\n";
                 echo "\t" . 'MageId: "' . $mageId . '"' . "\n";
                 echo "\t" . 'Short Description: "' . $short_description . '"' . "\n";
                 echo "\t" . 'Full Description: "' . $description . '"' . "\n";
                 echo "\t" . 'Status: "' . ProductStatus::get($statusId) . '"' . "\n";
                 echo "\t" . 'Manufacturer: id=' . $this->getManufacturerName(trim($additionAttrs['manufacturer']))->getId() . ', name="' . $this->getManufacturerName(trim($additionAttrs['manufacturer']))->getName() . '"' . "\n";
                 echo "\t" . 'Price: "' . $price . '"' . "\n";
                 echo "\t" . 'Weight: "' . $weight . '"' . "\n";
             }
             $asset = ($assetId = trim($product->getFullDescAssetId())) === '' || !($asset = Asset::getAsset($assetId)) instanceof Asset ? Asset::registerAsset('full_desc_' . $sku, $description, Asset::TYPE_PRODUCT_DEC) : $asset;
             $product->setName($name)->setMageId($mageId)->setShortDescription($short_description)->setFullDescAssetId(trim($asset->getAssetId()))->setIsFromB2B(true)->setStatus(ProductStatus::get($statusId))->setSellOnWeb(true)->setManufacturer($this->getManufacturerName(trim($additionAttrs['manufacturer'])))->save()->clearAllPrice()->addPrice(ProductPriceType::get(ProductPriceType::ID_RRP), $price)->addInfo(ProductInfoType::ID_WEIGHT, $weight);
             if ($specialPrice !== '') {
                 $product->addPrice(ProductPriceType::get(ProductPriceType::ID_CASUAL_SPECIAL), $specialPrice, $specialPrice_From, $specialPrice_To);
             }
             if (isset($additionAttrs['supplier']) && ($supplierName = trim($additionAttrs['supplier'])) !== '') {
                 $product->addSupplier(Supplier::create($supplierName, $supplierName, true));
             }
             if (isset($pro->categories) && count($pro->categories) > 0) {
                 $product->clearAllCategory();
                 foreach ($pro->category_ids as $cateMageId) {
                     if (!($category = ProductCategory::getByMageId($cateMageId)) instanceof ProductCategory) {
                         continue;
                     }
                     $product->addCategory($category);
                 }
             }
         }
         $systemSetting->setValue($updated_at)->save();
         if ($transStarted === false) {
             Dao::commitTransaction();
         }
     } catch (Exception $ex) {
         if ($transStarted === false) {
             Dao::rollbackTransaction();
         }
         throw $ex;
     }
     return $this;
 }
    //To Do: add operations
    //Transport
    //Pack
    $Estimates->save($GLOBALS['check_notify']);
    $Components = new EstimateComponents();
    $components_array = $Components->get_full_list("id", "parent_id='" . $ClientRequest->id . "'");
    for ($i = 0; $i < count($components_array); $i++) {
        $EstimateComponents = new EstimateComponents();
        $fields = $components_array[$i]->column_fields;
        foreach ($fields as $field) {
            $EstimateComponents->{$field} = $components_array[$i]->{$field};
        }
        $EstimateComponents->id = null;
        $EstimateComponents->date_entered = null;
        $EstimateComponents->date_modified = null;
        $EstimateComponents->created_by = null;
        $EstimateComponents->modified_user_id = null;
        $EstimateComponents->assigned_user_id = null;
        $EstimateComponents->assigned_user_name = null;
        $EstimateComponents->parent_bean = 'Estimates';
        $EstimateComponents->parent_id = $Estimates->id;
        $EstimateComponents->parent_name = $Estimates->name;
        $EstimateComponents->number = $EstimateComponents->generate_number('number', 'estimates_components', $Estimates->id, $Estimates->table_name);
        $EstimateComponents->save($GLOBALS['check_notify']);
    }
}
$productstatus = new ProductStatus();
if (isset($_REQUEST['status_action']) && !empty($_REQUEST['status_action'])) {
    $productstatus->update_product_status($_REQUEST['status_action'], $Estimates);
}
handleRedirect($Estimates->id, 'Estimates');
Example #15
0
 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $product = !isset($param->CallbackParameter->id) ? new Product() : Product::get(trim($param->CallbackParameter->id));
         if (!$product instanceof Product) {
             throw new Exception('Invalid Product passed in!');
         }
         if (!($manufacturer = Manufacturer::get(trim($param->CallbackParameter->manufacturerId))) instanceof Manufacturer) {
             throw new Exception('Invalid Manufacturer/Brand!');
         }
         if (!($status = ProductStatus::get(trim($param->CallbackParameter->statusId))) instanceof ProductStatus) {
             throw new Exception('Invalid Status!');
         }
         $sku = trim($param->CallbackParameter->sku);
         if (!isset($param->CallbackParameter->id) && ($sku === '' || Product::getBySku($sku) instanceof Product)) {
             throw new Exception('Invalid SKU (' . $sku . ') passed in OR already exist.');
         }
         $name = trim($param->CallbackParameter->name);
         $shortDescription = trim($param->CallbackParameter->shortDescription);
         $sellOnWeb = trim($param->CallbackParameter->sellOnWeb) === '1';
         $weight = doubleval(trim($param->CallbackParameter->weight));
         $product->setName($name)->setSku($sku)->setShortDescription($shortDescription)->setStatus($status)->setManufacturer($manufacturer)->setSellOnWeb($sellOnWeb)->setAsNewFromDate(trim($param->CallbackParameter->asNewFromDate))->setAsNewToDate(trim($param->CallbackParameter->asNewToDate))->setAssetAccNo(trim($param->CallbackParameter->assetAccNo))->setRevenueAccNo(trim($param->CallbackParameter->revenueAccNo))->setCostAccNo(trim($param->CallbackParameter->costAccNo))->setWeight($weight);
         if (trim($product->getId()) === '') {
             $product->setIsFromB2B(false);
         }
         $product->save();
         $this->_updateFullDescription($product, $param)->_updateCategories($product, $param)->_uploadImages($product, $param)->_setSupplierCodes($product, $param)->_setBarcodes($product, $param)->_setPrices($product, $param)->_setLocation($product, $param);
         $product->save();
         $results['url'] = '/product/' . $product->getId() . '.html';
         $results['item'] = $product->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
Example #16
0
echo "\n=====[" . date('Y-m-d H:i:s', $time_start) . "]系统【缺货,合并包裹缺货,自动拦截】共有(" . count($orders) . ")个订单需要处理\n";
foreach ($chunk_orders as $value_orders) {
    if (!empty($value_orders)) {
        foreach ($value_orders as $value) {
            BaseModel::begin();
            //开始事务
            $where = " WHERE id = " . $value['id'];
            $orderData = OrderindexModel::showOrderList($tableName, $where);
            //var_dump($orderData[$value['id']]);
            $returnStatus0 = array('orderStatus' => $orderData[$value['id']]['orderData']['orderStatus'], 'orderType' => $orderData[$value['id']]['orderData']['orderType']);
            $returnStatus = CommonModel::auto_contrast_intercept($orderData[$value['id']]);
            //自动拦截核心函数
            if ($returnStatus0 != $returnStatus) {
                if (OrderindexModel::updateOrder($tableName, $returnStatus, $where)) {
                    //echo "\n=====同步的订单状态成功======\n";
                    $ProductStatus = new ProductStatus();
                    if (!$ProductStatus->updateSkuStatusByOrderStatus(array($value['id']), $returnStatus['orderStatus'], $returnStatus['orderType'])) {
                        BaseModel::rollback();
                    }
                } else {
                    BaseModel::rollback();
                }
            }
            BaseModel::commit();
            BaseModel::autoCommit();
        }
    } else {
        echo "\n=====没有同步的订单======\n";
    }
}
$time_end = time();
Example #17
0
<?php

include_once __DIR__ . '/../framework.php';
// 加载框架
Core::getInstance();
// 初始化框架对象
include_once __DIR__ . '/../lib/productstatus.class.php';
// 加载框架
error_reporting(-1);
$product = new ProductStatus();
global $dbConn;
$updateSkuArr = array();
//$product->resetSkuStock("9306_M",1);
if (isset($argv[2])) {
    // 更新单个采购的料号
    //$sql = "select a.sku from pc_goods as a left join power_global_user as b on a.purchaseId=b.global_user_id where b.global_user_name='{$argv[2]}' ";
    echo $sql;
    //$sql = "select sku from pc_goods  ";
    $sql = $dbConn->execute($sql);
    $skuArr = $dbConn->getResultArray($sql);
    foreach ($skuArr as $item) {
        $updateSkuArr[] = $item['sku'];
    }
}
//$updateSkuArr = array("1724");
foreach ($updateSkuArr as $sku) {
    $product->resetSkuStock($sku, 1);
    //$product->calcAverageDailyCount($item['sku']);
    $product->resetSkuAverage($sku);
}
/*
Example #18
0
<?php

include_once __DIR__ . '/../framework.php';
// 加载框架
Core::getInstance();
// 初始化框架对象
include_once __DIR__ . '/../lib/productstatus.class.php';
// 加载框架
error_reporting(-1);
$product = new ProductStatus();
global $dbConn;
$updateSkuArr = $_POST['skuArr'];
$type = $_POST['type'];
if ($type == "getData") {
    $rtnArr = array();
    foreach ($updateSkuArr as $sku) {
        //$rtn = $product->resetSkuStock($sku,1);
        //$product->calcAverageDailyCount($item['sku']);
        $item = $product->getRealSkuData($sku);
        $rtnArr[$sku] = $item;
    }
    echo json_encode($rtnArr);
} else {
    foreach ($updateSkuArr as $sku) {
        //$rtn = $product->resetSkuStock($sku,1);
        //$product->calcAverageDailyCount($item['sku']);
        $product->resetSkuAverage($sku);
    }
}
    //To Do: add operations
    //Transport
    //Pack
    $ClientOrders->save($GLOBALS['check_notify']);
    $Components = new ClientorderComponents();
    $components_array = $Components->get_full_list("id", "parent_id='" . $ClientRequest->id . "'");
    for ($i = 0; $i < count($components_array); $i++) {
        $ClientorderComponents = new ClientorderComponents();
        $fields = $components_array[$i]->column_fields;
        foreach ($fields as $field) {
            $ClientorderComponents->{$field} = $components_array[$i]->{$field};
        }
        $ClientorderComponents->id = null;
        $ClientorderComponents->date_entered = null;
        $ClientorderComponents->date_modified = null;
        $ClientorderComponents->created_by = null;
        $ClientorderComponents->modified_user_id = null;
        $ClientorderComponents->assigned_user_id = null;
        $ClientorderComponents->assigned_user_name = null;
        $ClientorderComponents->parent_bean = 'ClientOrders';
        $ClientorderComponents->parent_id = $ClientOrders->id;
        $ClientorderComponents->parent_name = $ClientOrders->name;
        $ClientorderComponents->number = $ClientorderComponents->generate_number('number', 'clientorders_components', $ClientOrders->id, $ClientOrders->table_name);
        $ClientorderComponents->save($GLOBALS['check_notify']);
    }
}
$productstatus = new ProductStatus();
if (isset($_REQUEST['status_action']) && !empty($_REQUEST['status_action'])) {
    $productstatus->update_product_status($_REQUEST['status_action'], $ClientOrders);
}
handleRedirect($ClientOrders->id, 'ClientOrders');