Файл: Кафедра прикладной информатики Выпускная квалификационная работа разработка интернетмагазина по продаже женских наручных часов (система учета заказов для landing page).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 05.12.2023
Просмотров: 42
Скачиваний: 2
ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
Система ведения заказов
Пользователи
[[rslAddPrj->]]Новый проект[[<-rslAddPrj]]
[[rslEditPrj->]]Настройки[[<- rslEditPrj]]
[[rslAddOrders->]]Новый заказ[[<-rslAddOrders]]
[[rslViewStat->]]
id="statProj">Статистика[[<-rslViewStat]]
[[rslRequest->]]
id="requestBut">Заявки([[qNewReq]])[[<-rslRequest]]
[[subTitle]]
[[$orderTable]]
[[$printStat]]
64
[[$usersTable]]
[[$requestTable]]
[[$setting]]
[[$addPrj]]
[[$shopSetting]]
gp(json_encode(array(
'jsonrpc'=>'2.0',
'id'=>'1',
'method'=>'addTracking',
'params'=>
array(
'tracking'=>
array(
'tracking_number'=>$t,
'courier_slug'=>'russian-post',
'title'=>'Посылка')
)
)
));
}
function getTrackingInfo($tt){
return gp(json_encode(array(
'jsonrpc'=>'2.0',
'id'=>'1',
'method'=>'getTrackingInfo',
'params'=>
array(
'tracking'=>
array(
'tracking_number'=>$tt,
'courier_slug'=>'russian-post',
'title'=>'Посылка')
66
'jsonrpc'=>'2.0',
'id'=>'1',
'method'=>'addTracking',
'params'=>
array(
'tracking'=>
array(
'tracking_number'=>$t,
'courier_slug'=>'russian-post',
'title'=>'Посылка')
)
)
));
}
function getTrackingInfo($tt){
return gp(json_encode(array(
'jsonrpc'=>'2.0',
'id'=>'1',
'method'=>'getTrackingInfo',
'params'=>
array(
'tracking'=>
array(
'tracking_number'=>$tt,
'courier_slug'=>'russian-post',
'title'=>'Посылка')
66
) ) ));}
require 'connect.php';
function sendSms($text,$phone){
$phone = preg_replace('/\D/si','',$phone);
$phone = '7'.substr($phone, 1, strlen($phone));
$sms = file('http://sms.ru/sms/send?
api_id=************&to='.$phone.'&text='.urlencode($text));
return ($sms[0] == 100);
}
function prjInfo($id){
$prj = mysql_query("SELECT * FROM `projects` WHERE `id`='".$id."'");
if(mysql_num_rows($prj)) {
$prjInfo = mysql_fetch_assoc($prj);
$hourNow = date('H');
$prjInfo['maxHour'] = explode('-', trim($prjInfo['hourSms']));
$prjInfo['timeSms'] = ($hourNow >= $prjInfo['maxHour'][0] &&
$hourNow <= $prjInfo['maxHour'][1]) ? true : false;
return $prjInfo;
} else return false; }
$qa = mysql_query("SELECT * FROM `orders` WHERE
`status`='arrived' && `sms1`!='1' && `sms2`!='1' ");
if(mysql_num_rows($qa)){
while($ra = mysql_fetch_assoc($qa)){
$prjInfo = prjInfo($ra['project']);
if($prjInfo['timeSms']){
$ta = $prjInfo['textSms1'].' Почтовый идентификатор: '.$ra['track'];
67
if(sendSms($ta, $ra['phone']))
{ mysql_query("UPDATE `orders` SET `sms1`='1' WHERE `id`='".
$ra['id']."'"); }}
} }
$qn = mysql_query("SELECT * FROM `orders` WHERE status =
'arrived' && sms2 != '1' && TO_DAYS(CURDATE()) -
TO_DAYS(`dateStatus`) = (SELECT `daysSms2` FROM `projects` WHERE
`id`=`project`)");
if(mysql_num_rows($qn)){
while($rn = mysql_fetch_assoc($qn)){
$prjInfo = prjInfo($rn['project']);
if($prjInfo['timeSms']){
$tn = $prjInfo['textSms2'].' Почтовый идентификатор: '.$rn['track'];
if(sendSms($tn,$rn['phone']))
{ mysql_query("UPDATE `orders` SET `sms2`='1' WHERE `id`='".
$rn['id']."'"); } }} }
$q = mysql_query("SELECT * FROM `orders` WHERE `status` !=
'delivered' && `track`!='0'");
if(mysql_num_rows($q)){
while($r = mysql_fetch_assoc($q)){
$m = json_decode(addTracking(trim($r['track'])),$assoc=true);
$m = json_decode(getTrackingInfo(trim($r['track'])),
$assoc=true);
$nextTimeStatus = $m['result']['checkpoints'][0]['time'];
if(!empty($nextTimeStatus) && $nextTimeStatus !=
$r['dateStatus']){
68
{ mysql_query("UPDATE `orders` SET `sms1`='1' WHERE `id`='".
$ra['id']."'"); }}
} }
$qn = mysql_query("SELECT * FROM `orders` WHERE status =
'arrived' && sms2 != '1' && TO_DAYS(CURDATE()) -
TO_DAYS(`dateStatus`) = (SELECT `daysSms2` FROM `projects` WHERE
`id`=`project`)");
if(mysql_num_rows($qn)){
while($rn = mysql_fetch_assoc($qn)){
$prjInfo = prjInfo($rn['project']);
if($prjInfo['timeSms']){
$tn = $prjInfo['textSms2'].' Почтовый идентификатор: '.$rn['track'];
if(sendSms($tn,$rn['phone']))
{ mysql_query("UPDATE `orders` SET `sms2`='1' WHERE `id`='".
$rn['id']."'"); } }} }
$q = mysql_query("SELECT * FROM `orders` WHERE `status` !=
'delivered' && `track`!='0'");
if(mysql_num_rows($q)){
while($r = mysql_fetch_assoc($q)){
$m = json_decode(addTracking(trim($r['track'])),$assoc=true);
$m = json_decode(getTrackingInfo(trim($r['track'])),
$assoc=true);
$nextTimeStatus = $m['result']['checkpoints'][0]['time'];
if(!empty($nextTimeStatus) && $nextTimeStatus !=
$r['dateStatus']){
68
@mysql_query("UPDATE `orders` SET `status`='".$m['result']
['checkpoints'][0]['status']."', `fullStatus`='".$m['result']['checkpoints'][0]
['message']."
(".$m['result']['checkpoints'][0]['location_ru'].")',
`dateStatus`='".$nextTimeStatus."' WHERE `id`='".$r['id']."'"); } }
}
?>
Печать почтовых бланков
{
$request['apikey'] = "************************";
$all_to_md5 = $request;
$all_to_md5[] = "103103103";
$hash = md5(implode("|", $all_to_md5));
$request["hash"] = $hash;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://russianpostcalc.ru/api_v1.php");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($curl);
curl_close($curl);
if($data === false) return "10000 server error";
$res = json_decode($data, $assoc=true);
return $res;
69
}
function print_f7($params_arr)
{
$request = array(
"method"=>"print_f7p",
"print0"=>"0",
"printnalogkareq"=>"0",
"list"=>json_encode($params_arr));
return russianpostcalc_api_communicate($request);
}
function print_113($f113_oborot, $nalogka_ur_lico_cb, $params_arr)
{
$request = array(
"method"=>"print_f112",
"f113_oborot"=>(($f113_oborot==true)? 1:0),
"nalogka_ur_lico_cb"=>(($nalogka_ur_lico_cb==true)? 1:0),
"list"=>json_encode($params_arr));
return russianpostcalc_api_communicate($request);
}
require 'connect.php';
$q = mysql_query("SELECT * FROM `orders` WHERE `id`='".
$_GET['orderId']."'");
if(mysql_num_rows($q)){
70
$orderInfo = mysql_fetch_assoc($q);
$sqq = "SELECT * FROM `shop` WHERE `id`=(SELECT `shop` FROM
`projects` WHERE `id`='".$orderInfo['project']."') ";
$shop = mysql_fetch_assoc(mysql_query($sqq));
$worker = mysql_fetch_assoc(mysql_query("SELECT `fio` FROM `admins`
WHERE `id`='".$orderInfo['orderOfUser']."'"));
}
/*
function smallFio(){
global $shop;
if(preg_match_all('#([^ ]+)+#si',$prjInfo['fioFrom'],$m)){
mb_internal_encoding("UTF-8");
return $m[0][0].' '.mb_substr($m[0][1],0,1).'. '.mb_substr($m[0][2],0,1).'.';
} else return 'Ошибка ФИО';
return $shop['fioFrom'];
}
*/
$prm = array(array(
'from_index'=>$shop['index'],
'from_city'=>$shop['city'],
'from_state'=>"",
'from_country' => $shop['country'],
'from_addr'=>$shop['address'],
71
'from_fio'=>$worker['fio'],
'to_fio'=>$orderInfo['fio'],
'to_country'=>$orderInfo['country'],
'to_index'=>$orderInfo['index'],
'to_city'=>$orderInfo['city'],
'to_addr'=>$orderInfo['address'],
'ob_cennost_rub'=>$orderInfo['summa'],
'nalogka_rub'=>$orderInfo['summa']
));
if(isset($_GET['f7'])){ $ret = print_f7($prm); }
if(isset($_GET['f113'])){$ret = print_113(false,true,$prm); }
if($ret['msg']['type'] == "done"){
header("Location: ".$ret['link']." ");
}
Вывод заказов
function printOrdersTable(){
global $allOrders,$printOrders,$prj, $dts, $order, $orderTotal,$tdClass,
$qs, $date1, $date2, $userRsl, $userInfo, $orderRslEdit;
/// Вывести по дате if($date1 && $date2) $dts = "&& `date` BETWEEN '".
$date1['y']."-".$date1['m']."-".$date1['d']."' AND '".$date2['y']."-".
$date2['m']."-".$date2['d']." 23:59:59'";
else{
72
$date1 = @mysql_result(mysql_query("SELECT MIN(`date`)
FROM `orders` WHERE `project`='".$prj[id]."'"),0);
if($date1) $date1 = date('Y-m-d',strtotime($date1));
$date2 = date('Y-m-d');
dateToArr();
}
$allOrders = '';
if(isset($_GET['filter'])){
$fltr = " && ".$_GET['filter']." LIKE('%".$_GET['val']."%') ";
}
$ordOfUs= (!$userRsl['rslViewAnotherOrd']) ? " && orderOfUser='".
$userInfo['id']."'" : "";
$sql = "SELECT * FROM `orders` WHERE `project`='".$prj['id']."'
".$dts.$ordOfUs.$fltr." ORDER BY `date` DESC";
$q = mysql_query($sql);
$orderTotal = array('q'=>'0','s'=>'0','d'=>'0','r'=>'0');
$qs = array('1'=>'0','2'=>'0','3'=>'0','4'=>'0','5'=>'0');
if(mysql_num_rows($q)){
while($order = mysql_fetch_assoc($q)){
$order['fullStatus'] = preg_replace('/.*-/si','',$order['fullStatus']);
if(empty($order['status'])) { $tdClass = 'tdGray'; ++$qs[1]; }
73
elseif($order['status'] == 'delivered'){ $tdClass = 'tdGreen'; ++
$qs[4]; }
elseif($order['status'] == 'return-delivered'){ $orderTotal['r']++;
$tdClass = 'tdBlack'; ++$qs[5]; }
elseif($order['status'] == 'arrived'){ $tdClass = 'tdOrange'; ++
$qs[3]; }
else { $tdClass = 'tdBlue'; ++$qs[2]; }
$orderRslEdit = ($order['orderOfUser'] != $userInfo['id'] && !
$userRsl['rslEditAnotherOrd']) ? false : true;
$order['orderOfUserId'] = $order['orderOfUser'];
$order['orderOfUser'] = @mysql_result(mysql_query("SELECT
`fio` FROM `admins` WHERE `id`='".$order['orderOfUser']."'"),0);
$allOrders .= parseHtml('[[$zItem]]');
$orderTotal['q'] += $order['q'];
$orderTotal['s'] += $order['summa'];
$orderTotal['d'] += ($order['status'] == 'delivered') ?
$order['summa'] : 0;
}
} else $allOrders = 'Нет заказов.. ';
///////////
}
74
$qs[4]; }
elseif($order['status'] == 'return-delivered'){ $orderTotal['r']++;
$tdClass = 'tdBlack'; ++$qs[5]; }
elseif($order['status'] == 'arrived'){ $tdClass = 'tdOrange'; ++
$qs[3]; }
else { $tdClass = 'tdBlue'; ++$qs[2]; }
$orderRslEdit = ($order['orderOfUser'] != $userInfo['id'] && !
$userRsl['rslEditAnotherOrd']) ? false : true;
$order['orderOfUserId'] = $order['orderOfUser'];
$order['orderOfUser'] = @mysql_result(mysql_query("SELECT
`fio` FROM `admins` WHERE `id`='".$order['orderOfUser']."'"),0);
$allOrders .= parseHtml('[[$zItem]]');
$orderTotal['q'] += $order['q'];
$orderTotal['s'] += $order['summa'];
$orderTotal['d'] += ($order['status'] == 'delivered') ?
$order['summa'] : 0;
}
} else $allOrders = '
///////////
}
74