Posted by Anonymous on Mon 15th Jan 01:26 (modification of post by view diff)
diff | download | new post
- <?
- ###----------------------------------------------------------------------------------------------------------------###
- ################################################ ===== EVENTS HANDLER ===== ##########################################
- ###----------------------------------------------------------------------------------------------------------------###
- $default_query = "
- SELECT
- `ord`.`modified` AS `modified`,
- `ord`.`alert` AS `alert`,
- `ord`.`status` AS `status`,
- `ord`.`id` AS `id`,
- `ord`.`from` AS `from`,
- `ord`.`to` AS `to`,
- `ord`.`notes` AS `notes`,
- `c`.`name` AS `name`,
- `cust`.`name` AS `cust`
- FROM
- `orders` AS `ord`
- Left Join `clients` AS `c` ON (`ord`.`client` = `c`.`id`)
- Left Join `orders_customers` AS `cust` ON (`ord`.`id` = `cust`.`orderID`)
- WHERE ord.archived='0'
- ";
- {
- }
- $default_query .= "
- /*stat*//*stat*/
- GROUP BY ord.id
- ORDER BY /*sort*/`name` ASC/*sort*/
- ";
- if($event == 'find')
- {
- if($find['what'] == 'all' && $find['str'])
- {
- for($i = 0; $i < 4; $i++)
- {
- //////////////////////////////////////
- if($find['str'])
- {
- /*
- if($i == 0) $find['what'] = 'num';
- if($i == 1) $find['what'] = 'accountNr';
- if($i == 2) $find['what'] = 'cust';
- if($i == 3) $find['what'] = 'bono';
- */
- switch ($i)
- {
- case 0:
- $find['what'] = 'num';
- break;
- case 1:
- $find['what'] = 'accountNr';
- break;
- case 2:
- $find['what'] = 'cust';
- break;
- case 3:
- $find['what'] = 'bono';
- break;
- }
- $str = $find['str'];
- $array['num'] = "ord.id LIKE '".$str."'";
- $array['accountNr'] = "ord.accountID='".$str."'";
- $array['cust'] = "cust.name LIKE '%".$str."%' AND cust.orderID=ord.id";
- $array['bono'] = "h.bono LIKE '".$str."' AND h.orderID=ord.id";
- $cond[] = $array[$find['what']];
- }
- if($find['from'] && $find['to'])
- $cond[] = "ord.`from` >= '".$find['from']."' AND ord.`to` <= '".$find['to']."'";
- if($find['alert_from'] && $find['alert_to'])
- $cond[] = "(ord.deadline >= '".$find['alert_from']."' AND ord.deadline <= '".$find['alert_to']."' OR ord.alert >= '".$find['alert_from']."' AND ord.alert <= '".$find['alert_to']."')";
- if($find['price_from'] && $find['price_to'])
- {
- $find['price_from'] = validPrice($find['price_from']);
- $find['price_to'] = validPrice($find['price_to']);
- $cond[] = "ord.price >= '".$find['price_from']."' AND ord.price <= '".$find['price_to']."'";
- }
- if($find['client'])
- $cond[] = "ord.client='".$find['client']."'";
- if($find['country'])
- $cond[] = "ord.country='".$find['country']."'";
- if($find['hotel'])
- $cond[] = "h.orderID=ord.id AND h.hotel='".$find['hotel']."'";
- if($find['service'])
- $cond[] = "serv.orderID=ord.id AND serv.name='".$find['service']."'";
- $orders_search_query_temp[] = "SELECT ord.modified, ord.alert, ord.status, ord.`id`, ord.`from`, ord.`to`, ord.`notes`, ord.accountID, c.name, cust.name AS cust FROM orders ord, orders_hotels h ".($find['service']?', orders_services serv':'')." LEFT JOIN clients c ON(ord.client=c.id) LEFT JOIN orders_customers cust ON(ord.id=cust.orderID) WHERE ord.archived='".$deny."' /*stat*//*stat*/ ".$cond." GROUP BY ord.id ORDER BY /*sort*/`from`/*sort*/";
- //////////////////////////////////////
- }
- $orders_search_query = '('.implode(') UNION (', $orders_search_query_temp).') GROUP BY ord.id ORDER BY /*sort*/`from`/*sort*/';
- }
- else
- {
- if($find['str'])
- {
- //$str = explode(' ', $find['str']);
- //while(list($key, $val) = each($str))
- //{
- // if($val) $strBlock[] = $val;
- //}
- //$regexpr = implode('|', $strBlock);
- //$array['num'] = "ord.id REGEXP '".$regexpr."'";
- //$array['accountNr'] = "ord.accountID='".$regexpr."'";
- //$array['cust'] = "cust.name REGEXP '".$regexpr."' AND cust.orderID=ord.id";
- //$array['bono'] = "h.bono REGEXP '".$regexpr."' AND h.orderID=ord.id";
- $str = $find['str'];
- $array['num'] = "ord.id LIKE '".$str."'";
- $array['accountNr'] = "ord.accountID='".$str."'";
- $array['cust'] = "cust.name LIKE '%".$str."%' AND cust.orderID=ord.id";
- $array['bono'] = "h.bono LIKE '".$str."' AND h.orderID=ord.id";
- if($find['what'])
- $cond[] = $array[$find['what']];
- else
- }
- if($find['from'] && $find['to'])
- $cond[] = "ord.`from` >= '".$find['from']."' AND ord.`to` <= '".$find['to']."'";
- if($find['alert_from'] && $find['alert_to'])
- $cond[] = "(ord.deadline >= '".$find['alert_from']."' AND ord.deadline <= '".$find['alert_to']."' OR ord.alert >= '".$find['alert_from']."' AND ord.alert <= '".$find['alert_to']."')";
- if($find['price_from'] && $find['price_to'])
- {
- $find['price_from'] = validPrice($find['price_from']);
- $find['price_to'] = validPrice($find['price_to']);
- $cond[] = "ord.price >= '".$find['price_from']."' AND ord.price <= '".$find['price_to']."'";
- }
- if($find['client'])
- $cond[] = "ord.client='".$find['client']."'";
- if($find['country'])
- $cond[] = "ord.country='".$find['country']."'";
- if($find['hotel'])
- $cond[] = "h.orderID=ord.id AND h.hotel='".$find['hotel']."'";
- if($find['service'])
- $cond[] = "serv.orderID=ord.id AND serv.name='".$find['service']."'";
- if($cond)
- {
- $orders_search_query = "SELECT ord.modified, ord.alert, ord.status, ord.`id`, ord.`from`, ord.`to`, ord.`notes`, ord.accountID, c.name, cust.name AS cust FROM orders ord, orders_hotels h ".($find['service']?', orders_services serv':'')." LEFT JOIN clients c ON(ord.client=c.id) LEFT JOIN orders_customers cust ON(ord.id=cust.orderID) WHERE ord.archived='".$deny."' /*stat*//*stat*/ ".$cond." GROUP BY ord.id ORDER BY /*sort*/`from`/*sort*/";
- }
- else
- {
- $orders_search_query = $default_query;
- }
- }
- }
- {
- $sort = '`'.$sort.'`';
- if($match[1] == $sort) $sort .= ' DESC';
- }
- elseif($status)
- {
- }
- elseif($event == 'archive' && $logged_user['orders'] == 3 && $deny == 0)
- {
- cleanQueryBuffer();
- }
- {
- cleanQueryBuffer();
- }
- ###---------------------------------------------------------------------------------------------------------------###
- ################################################ ===== HTML PAGE ===== ##############################################
- ###---------------------------------------------------------------------------------------------------------------###
- if(!$orders_search_query) $orders_search_query = $default_query;
- ?>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1257">
- <meta http-equiv="Content-Language" content="et">
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="cache-control" content="no-cache">
- <title>Intranet</title>
- <link href="img/style.css" rel=stylesheet>
- <SCRIPT src="include/scripts.js" type="text/javascript"></SCRIPT>
- </head>
- <body text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">
- <form name="form1" method="POST">
- <table border="0" cellpadding="0" cellspacing="0" width="100%">
- <?
- if($debug=='1')
- {
- ?>
- <tr>
- <td colspan=14>
- <?
- echo $orders_search_query;
- ?>
- </td>
- </tr>
- <?
- }
- {
- if($data['id'])
- {
- $bg = 'bgcolor="'.$bgcolor[4].'"';
- else
- $bg = 'bgcolor="'.$bgcolor[$data['status']].'"';
- if($deny == 1) $bg = 'bgcolor="'.$bgcolor[0].'"';
- ?>
- <tr>
- <td <?=$bg?> style="cursor: pointer" onclick="javascript: parent.orders_edit.location.href='?page=orders_edit&orderID=<?=$data['id']?>'">
- <table border="0" cellpadding="0" cellspacing="0" width="100%">
- <tr>
- <td><img src="img/1x1.gif" width="1" height="3"></td>
- </tr>
- <tr>
- <?if($deny == 0 && $logged_user['orders'] == 3){?>
- <td width="20" align="right"><input type="checkbox" name="orders[]" value="<?=$data['id']?>"></td>
- <?}?>
- <td width="5"> </td>
- <td width="60"><?=$data['id']?></td>
- <td width="10"> </td>
- <td width="155"><?=$data['name']?> </td>
- <td width="10"> </td>
- <td width="70"><?=reverse_date($data['from'])?></td>
- <td width="10"> </td>
- <td width="70"><?=reverse_date($data['to'])?></td>
- <td width="10"> </td>
- <td width="100"><?=$data['cust']?> </td>
- <td width="10" > </td>
- <td><?=$data['notes']?> </td>
- <td width="5"> </td>
- </tr>
- <tr>
- <td><img src="img/1x1.gif" width="1" height="3"></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td width="719" bgcolor="#999999"><img border="0" src="img/1x1.gif" width="1" height="1"></td>
- </tr>
- <?
- }
- }
- ?>
- </table>
- </form>
- </body>
- </html>
Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.