Exemplo n.º 1
0
<?php

/* ******************************
 * WSDL aJax actions
 * ******************************
 */
set_time_limit(0);
include '../../includes/classes/core.php';
include '../../includes/classes/wsdl.class.php';
include '../../includes/classes/logger.class.php';
$action = $_REQUEST['act'];
$error = '';
$data = '';
$properties = GetCompanyProperties();
$wsdl = new wsdl('http://services.rs.ge/WayBillService/WayBillService.asmx?WSDL', 'mplus:406137014', '123456');
$_log = Logger::instance('../../log/wsdl/wsdl/', Logger::OFF);
switch ($action) {
    case 'sync':
        $array = array("create_date_s" => $_REQUEST['create_date_s'], "create_date_e" => $_REQUEST['create_date_e'], "waybill_number" => $_REQUEST['waybill_number'], "seller_tin" => $_REQUEST['seller_tin']);
        $array = array_diff($array, array(''));
        if (empty($array)) {
            $error = 'შეავსეთ სინქრონიზაციისათვის აუცილებელი ველი(ები)!';
        } else {
            $params = arrayToObject($array);
            $arr = $wsdl->get_buyer_waybills($params);
            for ($i = 0; $i < count($arr); $i++) {
                $wsdl->set_waybill_id($arr[$i]);
                $wsdl->get_waybill(1);
            }
            $arr = $wsdl->get_waybills($params);
            for ($i = 0; $i < count($arr); $i++) {
function AddReserve($overhead_id, $object)
{
    $req = mysql_query("SELECT  \t`OD`.`id` AS detail_id,\n\t\t\t\t\t\t\t\t\t`OD`.`goods_id` AS production_id,\n\t\t\t\t\t\t\t\t\t`OD`.`quantity`,\n\t\t\t\t\t\t\t\t\t`OD`.`price`,\n\t\t\t\t\t\t\t\t\t`O`.`activate_date`\n\t\t\t\t\t\tFROM \t\t`overhead_detail` AS `OD` \n\t\t\t\t\t\tLEFT JOIN \t`overhead` AS `O` ON `OD`.`overhead_id` = `O`.id\n\t\t\t\t\t\tWHERE \t\t`OD`.`overhead_id` = {$overhead_id}");
    while ($res = mysql_fetch_assoc($req)) {
        $c_data = date('Y-m-d H:i:s');
        $user_id = $_COOKIE['USERID'];
        $detail_id = $res['detail_id'];
        $price = $res['price'];
        $quantity = $res['quantity'];
        $production_id = $res['production_id'];
        $vat = 0;
        $prop = GetCompanyProperties();
        $pay = mysql_fetch_assoc(mysql_query("SELECT \t`partners`.`vat_payer` as `vat`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM \t\t`overhead`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN \t`partners` ON `overhead`.`seller_tin` = `partners`.`rs_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE \t\t`overhead`.`id` = {$overhead_id}"));
        //vat calculation
        if ($pay['vat'] == 1 && $prop['payer'] == 1) {
            $vat = $price - $price / 1.18;
            $price = $price / 1.18;
        }
        //get current price and quantity
        $prod = mysql_query("SELECT\t\t`price`,\n\t\t\t\t\t\t\t\t\t\tSUM(quantity - sold) AS `quantity`\n\t\t\t\t\t\t\tFROM\t\t`reserve`\n\t\t\t\t\t\t\tWHERE\t\t`production_id` = {$production_id}\n\t\t\t\t\t\t\tGROUP BY \t`production_id`");
        //calculate result self price
        $res_info = mysql_fetch_assoc($prod);
        $result_price = ($res_info[price] * $res_info[quantity] + $price * $quantity) / ($res_info[quantity] + $quantity);
        //insert production in reserve
        mysql_query("INSERT INTO `reserve`\n\t\t\t\t\t\t(user_id, `object_id`, `overhead_id`, `production_id`, `quantity`, `price`, `real_price`, `vat`, `create_date`)\n\t\t\t\t\t VALUES\n\t\t\t\t\t\t({$user_id}, {$object}, {$overhead_id}, {$production_id}, {$res['quantity']}, {$price}, {$res['price']}, {$vat}, '{$res['confirmation_date']}')");
        //if production already exist set self price and save in history
        if (mysql_num_rows($prod) != 0) {
            mysql_query("UPDATE `reserve`\n\t\t\t\t\t\tSET\t\t`price` = {$result_price}\n\t\t\t\t\t\tWHERE\t`production_id` = {$production_id}");
            //insert in history
            mysql_query("INSERT INTO self_cost_history\n\t\t\t\t\t\t\t(user_id, date, overhead_id, overhead_detail_id, production_id,  current_quantity, current_cost, income_quantity,   income_cost, result_quantity, result_cost)\n\t\t\t\t\t\t VALUES\n\t\t\t\t\t\t\t({$user_id}, '{$c_data}', {$overhead_id}, {$detail_id}, {$production_id}, {$res_info['quantity']}, {$res_info['price']}, {$res['quantity']}, {$price}, {$res_info['quantity']} + {$res['quantity']}, {$result_price})");
        } else {
            //insert in history first time
            mysql_query("INSERT INTO self_cost_history\n\t\t\t\t\t\t\t(user_id, date, overhead_id, overhead_detail_id, production_id,  current_quantity, current_cost, income_quantity,   income_cost, result_quantity, result_cost)\n\t\t\t\t\t\t VALUES\n\t\t\t\t\t\t\t({$user_id}, '{$c_data}', {$overhead_id}, {$detail_id}, {$production_id}, 0, 0, {$res['quantity']}, {$price}, {$res['quantity']}, {$price})");
        }
    }
}
function GetRelationsSection($res = '', $type, $stream)
{
    $prop = GetCompanyProperties();
    if ($stream == 0) {
        $data = '        
			<fieldset>
				<legend>გამყიდველი (გამგზავნი)</legend>
			
				<table width="95%" class="dialog-form-table">
					<tr>
						<td style="width: 200px;"><label for="seller_i_number">საიდენტ. ნომერი</label></td>
						<td style="width: 300px;"><label for="seller_name">დასახელება / სახელი, გვარი</label></td>
						<td style="width: 350px;"><label for="seller_addree">ტრანსპორტირების დაწყების ადგილი (მისამართი)</label></td>
					</tr>
					<tr>
						<td>
							<input type="text" id="seller_i_number" class="idle" disabled="disabled" onblur="this.className=\'idle\'" onfocus="this.className=\'activeField\'" value="' . $prop['tin'] . '" />
						</td>
						<td>
							<input type="text" id="seller_name" class="idle address" disabled="disabled" onblur="this.className=\'idle address\'" onfocus="this.className=\'activeField address\'" value="' . $prop['name'] . '" />
						</td>
						<td>
							<input type="text" id="seller_addree" class="idle large" disabled="disabled" onblur="this.className=\'idle large\'" onfocus="this.className=\'activeField large\'" value="' . $prop['address'] . '" />
						</td>
					</tr>
				</table>
			</fieldset>
		';
    } else {
        $data = '        
			<fieldset>
				<legend>გამყიდველი (გამგზავნი)</legend>
			
				<table width="95%" class="dialog-form-table">
					<tr>
						<td style="width: 200px;"><label for="seller_i_number">საიდენტ. ნომერი</label></td>
						<td style="width: 300px;"><label for="seller_name">დასახელება / სახელი, გვარი</label></td>
						<td style="width: 350px;"><label for="seller_addree">ტრანსპორტირების დაწყების ადგილი (მისამართი)</label></td>
					</tr>
					<tr>
						<td>
							<input type="text" id="seller_i_number" class="idle" disabled="disabled" onblur="this.className=\'idle\'" onfocus="this.className=\'activeField\'" value="' . $res['seller_tin'] . '" />
						</td>
						<td>
							<input type="text" id="seller_name" class="idle address" disabled="disabled" onblur="this.className=\'idle address\'" onfocus="this.className=\'activeField address\'" value="' . $res['seller_name'] . '" />
						</td>
						<td>
							<input type="text" id="seller_addree" class="idle large" disabled="disabled" onblur="this.className=\'idle large\'" onfocus="this.className=\'activeField large\'" value="' . $res['start_address'] . '" />
						</td>
					</tr>
				</table>
			</fieldset>
		';
    }
    if ($type != 1 && $type != 4) {
        //1 is Domestic Traffic, 4 is Distribution
        $data .= '        
			<fieldset>
				<legend>მყიდველი (მიმღები)</legend>
			
				<table width="95%" class="dialog-form-table">
					<tr>
						<td style="width: 200px;"><label for="buyer_i_number">საიდენტ. ნომერი</label></td>
						<td style="width: 300px;"><label for="buyer_name">დასახელება / სახელი, გვარი</label></td>
						<td style="width: 350px;"><label for="buyer_addree">ტრანსპორტირების დაწყების ადგილი (მისამართი)</label></td>
					</tr>
					<tr>
						<td>
							<input type="text" id="buyer_i_number" class="idle" onblur="this.className=\'idle\'" onfocus="this.className=\'activeField\'" value="' . $res['buyer_tin'] . '" />
						</td>
						<td>
							<div class="seoy-row" id="buyer_name_seoy">
								<input type="text" id="buyer_name" class="idle seoy-address" onblur="this.className=\'idle seoy-address\'" onfocus="this.className=\'activeField seoy-address\'" value="' . $res['buyer_name'] . '" />
								<button id="buyer_name_btn" class="combobox">buyer_name</button>
							</div>
						</td>
						<td>
							<input type="text" id="buyer_addree" class="idle large" onblur="this.className=\'idle large\'" onfocus="this.className=\'activeField large\'" value="' . $res['end_address'] . '" />
						</td>
					</tr>
				</table>
			</fieldset>
		';
    }
    return $data;
}
Exemplo n.º 4
0
function GetRelationsSection($res = '', $type, $stream)
{
    if ($type == 3) {
        $disable = "display: none;";
    }
    $prop = GetCompanyProperties();
    if ($stream == 0) {
        $data = '        
			<fieldset>
				<legend>გამყიდველი (გამგზავნი)</legend>
			
				<table width="95%" class="dialog-form-table">
					<tr>
						<td style="width: 480px;"><label for="seller_i_number">საიდენტ. ნომერი</label></td>
						<td style="width: 300px;"><label for="seller_name">დასახელება / სახელი, გვარი</label></td>
						<td style="width: 350px;"><label for="seller_addree">ტრანსპორტირების დაწყების ადგილი (მისამართი)</label></td>
					</tr>
					<tr>
						<td>
							<input type="text" id="seller_i_number" class="idle" disabled="disabled" onblur="this.className=\'idle\'" onfocus="this.className=\'activeField\'" value="' . $prop['tin'] . '" />
						</td>
						<td>
							<input type="text" id="seller_name" class="idle address" disabled="disabled" onblur="this.className=\'idle address\'" onfocus="this.className=\'activeField address\'" value="' . $prop['name'] . '" />
						</td>
						<td>
							<input type="text" id="seller_addree" class="idle large" disabled="disabled" onblur="this.className=\'idle large\'" onfocus="this.className=\'activeField large\'" value="' . $prop['address'] . '" />
						</td>
					</tr>
				</table>
			</fieldset>
		';
    } else {
        $data = '        
			<fieldset>
				<legend>გამყიდველი (გამგზავნი)</legend>
			
				<table width="95%" class="dialog-form-table">
					<tr>
						<td style="width: 200px;"><label for="seller_i_number">საიდენტ. ნომერი</label></td>
						<td style="width: 300px;"><label for="seller_name">დასახელება / სახელი, გვარი</label></td>
						<td style="width: 350px;"><label for="seller_addree">ტრანსპორტირების დაწყების ადგილი (მისამართი)</label></td>
					</tr>
					<tr>
						<td>
							<input type="text" id="seller_i_number" class="idle" disabled="disabled" onblur="this.className=\'idle\'" onfocus="this.className=\'activeField\'" value="' . $res['seller_tin'] . '" />
						</td>
						<td>
							<input type="text" id="seller_name" class="idle address" disabled="disabled" onblur="this.className=\'idle address\'" onfocus="this.className=\'activeField address\'" value="' . $res['seller_name'] . '" />
						</td>
						<td>
							<input type="text" id="seller_addree" class="idle large" disabled="disabled" onblur="this.className=\'idle large\'" onfocus="this.className=\'activeField large\'" value="' . $res['start_address'] . '" />
						</td>
					</tr>
				</table>
			</fieldset>
		';
    }
    if ($type != 1 && $type != 4) {
        //1 is Domestic Traffic, 4 is Distribution
        $data .= '        
			<fieldset>
				<legend>მყიდველი (მიმღები)</legend>
			
				<table width="95%" class="dialog-form-table">
					<tr>
		    
						<td style="width: 200px;"><label for="buyer_i_number">საიდენტ. ნომერი(დასახელება / სახელი, გვარი)</label></td>						
						<td style="width: 300px; ' . $disable . '"><label for="buyer_addree">ტრანსპორტირების დასრულები ადგილი (მისამართი)</label></td>
		                
					</tr>
					<tr>
						<td>
							<select data-adress="" style="width:400px !important" id="buyer_i_number">' . GetBuyer_opt($res['buyer_tin']) . ' </select> 
						</td>
						<td style="' . $disable . '">
							<input type="text" id="buyer_addree" class="idle large" onblur="this.className=\'idle large\'" onfocus="this.className=\'activeField large\'" value="' . $res['end_address'] . '" />
						</td>
						
					</tr>
							    		    
				</table>
					    			    
			</fieldset>
		';
    }
    return $data;
}