Пример #1
0
Файл: doc.php Проект: nikuha/rs
         } else {
             $client_arr = $arr['clients'] ? explode(",", $arr['clients']) : array();
             $arr['fio_list'] = array();
             $plus = preg_split("/[\r\n]/", $arr['plus']);
             foreach ($client_arr as $k => $v) {
                 $sql1 = mysql_query("SELECT * FROM " . TABLE_CLIENT . " WHERE client_id='{$v}'") or Error(1, __FILE__, __LINE__);
                 if ($client = @mysql_fetch_array($sql1)) {
                     $name = $client['name'];
                     if ($arr['plus'] && isset($plus[$k])) {
                         $name .= ' ' . $plus[$k];
                     }
                     $arr['fio_list'][] = $name;
                 }
             }
         }
         list($arr['total'], $arr['provider_sum'], $arr['agentsum']) = get_agentsum($arr['total'], $arr['inall'], $arr['provider_sum'], $arr['debt'], $arr['paid_debt'], $arr['paytoprovider']);
         $replace['total'] += $arr['total'];
         $replace['provider_sum'] += $arr['provider_sum'];
         $replace['agentsum'] += $arr['agentsum'];
         $order_list[] = $arr;
     }
 }
 if ($type == 1 && $i_count) {
     $replace['order_list'] = $order_list;
     if (!$office_id) {
         $office_id = 1;
     }
     $office_arr = array('region', 'name', 'director', 'director1', 'inn', 'kpp', 'rs', 'ks', 'bank', 'bik', 'licence', 'address', 'phone', 'fax', 'email');
     $sql = mysql_query("SELECT *  FROM " . TABLE_OFFICE . " \n\t\t\tWHERE office_id={$office_id}") or Error(1, __FILE__, __LINE__);
     $arr = @mysql_fetch_array($sql);
     foreach ($office_arr as $v) {
Пример #2
0
Файл: func.php Проект: nikuha/rs
function generate_order($order_id, $type, $stamp)
{
	global $office_arr, $provider_arr, $rus_month_1, $admin_region_list;
	$office_fields = array();
	foreach($office_arr as $v) $office_fields[] = "of.$v as office_$v";
	foreach($provider_arr as $v) $office_fields[] = "pr.$v as provider_$v";
	$of_sql = join(', ', $office_fields);
	
	$sql = mysql_query("
		SELECT 
			z.*, ob.name as object_name, ob.address as object_address,
			ct.name as city_name, c.name as country_name, c.country_id,
			of.doctop, u.name as username, u.email as admin_email, u.name as admin_name,
			$of_sql
		FROM 
			".TABLE_ORDER." z 
			LEFT JOIN ".TABLE_OBJECT." ob on (ob.object_id=z.object_id) 
			LEFT JOIN ".TABLE_CITY." ct ON (ob.city_id=ct.city_id)
			LEFT JOIN ".TABLE_COUNTRY." c ON (ct.country_id=c.country_id)
			LEFT JOIN ".TABLE_OFFICE." of ON (z.office_id=of.office_id)
			LEFT JOIN ".TABLE_PROVIDER." pr ON (z.provider_id=pr.provider_id)
			LEFT JOIN ".TABLE_USER." u on (u.user_id=z.user_id) 
		WHERE
			z.order_id=$order_id AND ob.object_id>0
		GROUP BY
			z.order_id
		LIMIT
			1
		") or Error(1, __FILE__, __LINE__);
	if(!($arr = @mysql_fetch_array($sql))) return false; 
	
	if($arr['country_id']==25) {$arr['country_name'] = ''; $arr['city_name'] = ''; }
	
	list($y_ld,$m_ld,$d_ld) = explode("-", $arr['date_from']);
	$i=-1;
	do 
	{
		$i++;
		$ts = mktime(0,0,0,$m_ld,31-$i,$y_ld);
		
	} while(!checkdate($m_ld,31-$i,$y_ld));
	
	$arr['date_lastday'] = sql_to_text_date(date("Y-m-d", $ts));
	
	$arr['date_zayavka'] = sql_to_text_date($arr['date']);
	$arr['date_from'] = sql_to_text_date($arr['date_from']);
	$arr['date_to_rus'] = sql_to_text_date($arr['date_to'], 1);
	$arr['date_to'] = sql_to_text_date($arr['date_to']);
	
	$arr['date_pay_rus'] = sql_to_text_date($arr['date_pay'], 1);
	
	if($arr['fio'])
	{
		$arr['fio_list'] = preg_split("/[\r\n]+/", $arr['fio']);
		$arr['pasport'] = preg_split("/[\r\n]+/", $arr['pasport']);
		$arr['birthday'] = preg_split("/[\r\n]+/", $arr['birthday']);
		$arr['tphone'] = preg_split("/[\r\n]+/", $arr['tphone']);
	}
	else
	{
		$client_arr = $arr['clients'] ? explode(",", $arr['clients']) : array();
		
		$arr['fio_list'] = array();
		$arr['pasport'] = array();
		$arr['birthday'] = array();
		$arr['birthday_city'] = array();
		$arr['tphone'] = array();
		
		$plus = preg_split("/[\r\n]/", $arr['plus']);

		foreach($client_arr as $k=>$v) 
		{
			$sql = mysql_query("SELECT * FROM ".TABLE_CLIENT." WHERE client_id='$v'") or Error(1, __FILE__, __LINE__);
			if($client = @mysql_fetch_array($sql)) 
			{
				$name = $client['name'];
				if($arr['plus'] && isset($plus[$k])) $name .= ' '.$plus[$k];
				$arr['fio_list'][] = $name;
				$arr['pasport'][] = $client['pasport'];
				$arr['birthday'][] = sql_to_text_date($client['birthday'], 0, 1);
				$arr['birthday_city'][] = $client['birthday_city'];
				$arr['tphone'][] = $client['phone'];
			}
		}
	}
	
	$arr['amount_list'] = explode(",", $arr['amount']);
	$arr['price_list'] = explode(",", $arr['price']);
	$arr['summa_list'] = explode(",", $arr['summa']);
	
	if(!$arr['discount'] && $arr['skidka']) 
	{
		$arr['discount'] = $arr['total'] - $arr['inall'];
	}
	
	list($arr['total_doc'], $arr['provider_sum'], $arr['agentsum_doc']) = 
		get_agentsum($arr['total'], $arr['inall'], $arr['provider_sum'], $arr['debt'], $arr['paid_debt'], $arr['paytoprovider']);
	
	
	$arr['date'] = date("d.m.y");
	$arr['date_rus'] =  '"'.date("d").'" '.$rus_month_1[(int)date("m")]." ".date("Y");
	$arr['date_full'] = date("d.m.Y");
	$arr['time'] = date("H:i");
	
	$arr['note'] = nl2br($arr['note']);
	$arr['suite_descr'] = nl2br($arr['suite_descr']);
	$arr['extra'] = nl2br($arr['extra']);
	
	$arr['suite_st'] = nl2br($arr['suite_st']);
	
	$arr['provider_rekvizit_string'] = ereg_replace("(\r)?\n", ", ", $arr['provider_rekvizit']);
	$arr['provider_rekvizit'] = nl2br($arr['provider_rekvizit']);
	$arr['client_rekvizit'] = nl2br($arr['client_rekvizit']);
	
	$arr['region_name'] = $arr['office_region'];
	
	$arr['stamp'] = $stamp;
	if($stamp)
	{
		$arr['act_img'] = get_img_code("act_$arr[office_id].jpg"); 
		$arr['stamp_img'] = get_img_code("stamp_$arr[office_id].png");  
		$arr['otchetagenta_img'] = get_img_code("otchetagenta_$arr[office_id].jpg"); 		
		$arr['schet_img'] = get_img_code("schet_$arr[office_id].jpg"); 
		$arr['dogovor_img'] = get_img_code("dogovor_$arr[office_id].jpg");  
	}
	
	$arr['direktora'] = $arr['office_id']==7 ? 'Директора' : 'Генерального директора';
	$arr['direktor'] = $arr['office_id']==7 ? 'Директор' : 'Генеральный директор';

	if($type=='dogovor') 
	{
		$file = $arr['person'] ? 'dogovor_oper_f' : 'dogovor_oper_u';
	}
	elseif($type=='dogovor2')
	{
		$file = $arr['person'] ? 'dogovor_otel_f' : 'dogovor_otel_u';
	}
	elseif($type=='dogovor3')
	{
		$file = $arr['person'] ? 'dogovor_uslugi_f' : 'dogovor_uslugi_u';
	}
	else $file = $type;  
	$text = get_template("templ/doc/$file.htm", $arr);
	//$text = escape_string($text);
	
	$sql = mysql_query("SELECT doc_id FROM ".TABLE_DOC." WHERE order_id=$order_id AND type='$type'") 
		or Error(1, __FILE__, __LINE__);
	$arr = @mysql_fetch_array($sql);	
	if($doc_id = @$arr[doc_id])
	{
		mysql_query("UPDATE ".TABLE_DOC." SET date=CURDATE(), stamp=$stamp 
			WHERE doc_id=$doc_id") 
			or Error(1, __FILE__, __LINE__);
	}
	else	
	{
		mysql_query("INSERT INTO ".TABLE_DOC." SET order_id=$order_id, type='$type', date=CURDATE(),
				stamp=$stamp") 
			or Error(1, __FILE__, __LINE__);
		$doc_id = mysql_insert_id();
	}
			
	$fn = "doc/$doc_id.htm";
	$f = fopen($fn, 'w');
	fwrite($f, $text);
	fclose($f);
	
	
	return true;
}
Пример #3
0
Файл: pay.php Проект: nikuha/rs
    $sql_pays = mysql_query("SELECT * FROM " . TABLE_INVENTORY . " WHERE order_id='{$order_id}' ORDER BY date") or Error(1, __FILE__, __LINE__);
    while ($arr_pays = @mysql_fetch_array($sql_pays)) {
        if ($arr_pays['summa'] > 0) {
            $replace['plus'] += $arr_pays['summa'];
        } else {
            $replace['minus'] += -$arr_pays['summa'];
        }
        $arr_pays['date'] = sql_to_text_date($arr_pays['date'], 0, 1);
        $arr_pays['summa'] = $arr_pays['summa'] > 0 ? "+ " . separ_float($arr_pays['summa']) : separ_float($arr_pays['summa']);
        $arr_pays['payform'] = $arr_pays['cash'] ? 'наличные' : ($arr_pays['emoney'] ? 'электронные' : 'безналичный');
        $arr_pays['name'] = htmlspecialchars($arr_pays['name'], ENT_COMPAT, 'cp1251');
        $arr_pays['del_link'] = "?p=pay&delinventory={$arr_pays['inventory_id']}&order_id={$order_id}";
        $other_payment[] = $arr_pays;
    }
    $replace['other_payment'] = $other_payment;
    list($replace['total_doc'], $replace['providersum'], $replace['agentsum_doc']) = get_agentsum($replace['total'], $replace['inall'], $replace['provider_sum'], $replace['debt'], $replace['paid_debt'], $replace['paytoprovider']);
    $content = get_template('templ/order_edit4.htm', $replace);
    return;
}
$replace = array();
$data = @unserialize($_SESSION['pay_data']);
foreach ($pay_arr as $v) {
    ${$v} = @$data[$v];
}
if ($datesel == 1) {
    $d_field = 'date_from';
} else {
    $d_field = 'date';
}
$replace['datesel'] = $datesel;
$replace['objectlist'] = $objectlist;