PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/foodcenter/statchange.php

http://lansuite.googlecode.com/
PHP | 275 lines | 237 code | 28 blank | 10 comment | 32 complexity | b4c70075c5961c88c2e1dd439b4e8e1b MD5 | raw file
Possible License(s): LGPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. include_once("modules/foodcenter/class_product.php");
  3. include_once("modules/foodcenter/class_accounting.php");
  4. $product_list = new product_list();
  5. if($auth['type'] < 2){
  6. unset($_GET['step']);
  7. }
  8. switch ($_GET['step']) {
  9. case 3:
  10. $time = time();
  11. if($_GET['status'] == 6 | $_GET['status'] == 7){
  12. $db->qry("UPDATE %prefix%food_ordering SET status = %string%, lastchange = %string%, supplytime = %string% WHERE id = %int%", $_GET['status'], $time, $time, $_GET['id']);
  13. }elseif ($_GET['status'] == 8){
  14. $prodrow = $db->qry_first("SELECT * FROM %prefix%food_ordering WHERE id = %int%", $_GET['id']);
  15. if($prodrow['pice'] > 1 && !isset($_POST['delcount'])){
  16. $count_array[] = "<option selected value=\"{$prodrow['pice']}\">".t('Alle')."</option>";
  17. for($i = $prodrow['pice'];$i > 0;$i--){
  18. $count_array[] .= "<option value=\"{$i}\">{$i}</option>";
  19. }
  20. $_GET['step'] = 10;
  21. }else{
  22. $price = 0;
  23. $account = new accounting($prodrow['userid']);
  24. if(stristr($prodrow['opts'],"/")){
  25. $values = explode("/",$prodrow['opts']);
  26. foreach ($values as $number){
  27. if(is_numeric($number)){
  28. $optrow = $db->qry_first("SELECT price FROM %prefix%food_option WHERE id = %int%", $number);
  29. $price += $optrow['price'];
  30. }
  31. }
  32. }else{
  33. $optrow = $db->qry_first("SELECT price FROM %prefix%food_option WHERE id = %int%", $prodrow['opts']);
  34. $price += $optrow['price'];
  35. }
  36. if(isset($_POST['delcount'])){
  37. $price = $price * $_POST['delcount'];
  38. }else{
  39. $price = $price * $prodrow['pice'];
  40. }
  41. $account->change($price,t('Rόckzahlung bei abbestellten Produkten') . " (" . $auth['username'] . ")",$prodrow['userid']);
  42. if(!isset($_POST['delcount']) || $_POST['delcount'] == $prodrow['pice']){
  43. $db->qry_first("DELETE FROM %prefix%food_ordering WHERE id = %int%", $_GET['id']);
  44. }else{
  45. $pice = $prodrow['pice'] - $_POST['delcount'];
  46. $db->qry_first("UPDATE %prefix%food_ordering SET pice = %int% WHERE id = %int%", $pice, $_GET['id']);
  47. }
  48. }
  49. }else{
  50. $db->qry("UPDATE %prefix%food_ordering SET status = %string%, lastchange = %string% WHERE id = %int%", $_GET['status'], $time, $_GET['id']);
  51. if($_GET['status'] == 3){
  52. $user_id = $db->qry_first("SELECT userid FROM %prefix%food_ordering WHERE id = %int%", $_GET['id']);
  53. $func->setainfo(t('Deine bestellten Produkte sind abholbereit'),$user_id['userid'],2,"foodcenter",$_GET['id']);
  54. }
  55. }
  56. break;
  57. }
  58. switch ($_GET['step']){
  59. default:
  60. include_once('modules/mastersearch2/class_mastersearch2.php');
  61. $ms2 = new mastersearch2('news');
  62. $ms2->query['from'] = "%prefix%food_ordering AS a
  63. LEFT JOIN %prefix%food_option AS o ON a.opts = o.id
  64. LEFT JOIN %prefix%food_product AS p ON a.productid = p.id
  65. LEFT JOIN %prefix%food_supp AS s ON p.supp_id = s.supp_id
  66. LEFT JOIN %prefix%user AS u ON u.userid = a.userid";
  67. // Array Abfragen fόr DropDowns
  68. $status_list = array('' => 'Alle');
  69. $row = $db->qry("SELECT * FROM %prefix%food_status");
  70. while($res = $db->fetch_array($row)) $status_list[$res['id']] = $res['statusname'];
  71. $db->free_result($row);
  72. $supp_list = array('' => 'Alle');
  73. $row = $db->qry("SELECT * FROM %prefix%food_supp");
  74. while($res = $db->fetch_array($row)) $supp_list[$res['supp_id']] = $res['name'];
  75. $db->free_result($row);
  76. $party_list = array('' => 'Alle');
  77. $row = $db->qry("SELECT party_id, name FROM %prefix%partys");
  78. while($res = $db->fetch_array($row)) $party_list[$res['party_id']] = $res['name'];
  79. $db->free_result($row);
  80. $ms2->AddTextSearchDropDown('Status', 'a.status', $status_list, '1');
  81. $ms2->AddTextSearchDropDown('Lieferant', 's.supp_id', $supp_list);
  82. $ms2->AddTextSearchDropDown('Party', 'a.partyid', $party_list, $party->party_id);
  83. /*
  84. $userquery = $db->qry("SELECT * FROM %prefix%food_ordering AS a LEFT JOIN %prefix%user AS u ON a.userid=u.userid");
  85. $user_array[''] = t('');
  86. while ($userrows = $db->fetch_array($userquery)) {
  87. $user_array[$userrows['userid']] = $userrows['username'];
  88. }
  89. $ms2->AddTextSearchDropDown('Besteller', 'a.userid', $user_array);
  90. */
  91. $ms2->AddSelect('u.userid');
  92. $ms2->AddResultField('Titel', 'p.caption');
  93. //$ms2->AddResultField('Option', 'o.caption');
  94. $ms2->AddResultField('Einheit', 'o.unit');
  95. $ms2->AddResultField('Anzahl', 'a.pice');
  96. $ms2->AddResultField('Lieferant', 's.name');
  97. $ms2->AddResultField('Besteller', 'u.username', 'UserNameAndIcon');
  98. $ms2->AddResultField('Bestellt', 'a.ordertime', 'MS2GetDate');
  99. $ms2->AddResultField('Geliefert', 'a.supplytime', 'MS2GetDate');
  100. $ms2->AddIconField('details', 'index.php?mod=foodcenter&action=statchange&step=2&id=', t('Details'));
  101. $fc_ordered_status_quest[0] = t('Status δndern: Abgeholt');
  102. $fc_ordered_status_quest[1] = t('Status δndern: Abholbereit');
  103. $fc_ordered_status_quest[2] = t('Status δndern: Lieferung erwartet');
  104. $fc_ordered_status_quest[3] = t('Status δndern: An Platz geliefert');
  105. $fc_ordered_status_quest[4] = t('Produkt abbestellen und Geld zurόckόberweisen.');
  106. $fc_ordered_status_quest[5] = t('Zurόck');
  107. $ms2->AddMultiSelectAction($fc_ordered_status_quest[0], 'index.php?mod=foodcenter&action=statchange&step=2&status=6', 1);
  108. $ms2->AddMultiSelectAction($fc_ordered_status_quest[1], 'index.php?mod=foodcenter&action=statchange&step=2&status=5', 1);
  109. $ms2->AddMultiSelectAction($fc_ordered_status_quest[2], 'index.php?mod=foodcenter&action=statchange&step=2&status=3', 1);
  110. $ms2->AddMultiSelectAction($fc_ordered_status_quest[3], 'index.php?mod=foodcenter&action=statchange&step=2&status=7', 1);
  111. $ms2->AddMultiSelectAction($fc_ordered_status_quest[4], 'index.php?mod=foodcenter&action=statchange&step=2&status=8', 1);
  112. switch ($_POST['search_dd_input'][0]){
  113. case 1:
  114. $dsp->NewContent(t('Bestellte Produkte'), '');
  115. $ms2->NoItemsText = t('Keine aktuellen Bestellungen vorhanden.');
  116. break;
  117. case 2:
  118. $dsp->NewContent(t('Produkte die bestellt werden'), '');
  119. $ms2->NoItemsText = t('Es mόssen keine Produkte bestellt werden.');
  120. break;
  121. case 3:
  122. $dsp->NewContent(t('Diese Produkte wurden bestellt. Auf die Lieferung wird gewartet.'), '');
  123. $ms2->NoItemsText = t('Es wird auf keine Lieferung gewartet.');
  124. break;
  125. case 4:
  126. $dsp->NewContent(t('Fertiggestellte Kόchengerichte zur Abholung/Lieferung'), '');
  127. $ms2->NoItemsText = t('Derzeit gibt es keine fertiggestellten Gerichte aus der Kόche.');
  128. break;
  129. case 5:
  130. $dsp->NewContent(t('Abgeholt'), '');
  131. $ms2->NoItemsText = t('Du hast alle Produkte abgeholt.');
  132. break;
  133. }
  134. $ms2->PrintSearch('index.php?mod=foodcenter&action=statchange', 'a.id');
  135. $handle = opendir("ext_inc/foodcenter_templates");
  136. while ($file = readdir ($handle)) if (($file != ".") and ($file != "..") and ($file != ".svn") and (!is_dir($file))) {
  137. if((substr($file, -3, 3) == "htm") && (substr($file, -7, 7) != "row.htm") || (substr($file, -4, 4) == "html") && (substr($file, -8, 8) != "row.html")){
  138. $file_array[] .= "<option value=\"$file\">$file</option>";
  139. }
  140. }
  141. $dsp->SetForm("index.php?mod=foodcenter&action=print&design=base\" target=\"_blank\"","print");
  142. $dsp->AddDropDownFieldRow("file",t('Bitte Template auswδhlen:'),$file_array,"");
  143. $MainContent .= "<input type=\"hidden\" name=\"search_input[0]\" value=\"{$_POST['search_input'][0]}\">\n";
  144. $MainContent .= "<input type=\"hidden\" name=\"search_dd_input[0]\" value=\"{$_POST['search_dd_input'][0]}\">\n";
  145. $MainContent .= "<input type=\"hidden\" name=\"search_dd_input[1]\" value=\"{$_POST['search_dd_input'][1]}\">\n";
  146. $MainContent .= "<input type=\"hidden\" name=\"search_dd_input[2]\" value=\"{$_POST['search_dd_input'][2]}\">\n";
  147. $dsp->AddFormSubmitRow(t('Drucken'));
  148. $dsp->AddContent();
  149. break;
  150. case 2:
  151. if($_POST['action']){
  152. include_once("modules/seating/class_seat.php");
  153. $seat2 = new seat2();
  154. $time = time();
  155. $totprice = 0;
  156. foreach($_POST["action"] AS $item => $val) {
  157. if($_GET["status"] == 6 | $_GET["status"] == 7){
  158. $db->qry("UPDATE %prefix%food_ordering SET status = %string%, lastchange = %string%, supplytime = %string% WHERE id = %string%", $_GET["status"], $time, $time, $item);
  159. //sitzplan popup einbinden
  160. //change by jan fόr sitzplatz popup $item = id in food_ordering table
  161. //unit food_option (grφίe)
  162. $abfrage = $db->qry_first("SELECT %prefix%food_ordering.userid AS userid,%prefix%food_ordering.pice AS pice,unit, %prefix%food_product.caption AS caption, username, name, firstname
  163. FROM %prefix%food_ordering,%prefix%food_option, %prefix%food_product, %prefix%user
  164. WHERE %prefix%food_ordering.id = ".$item."
  165. AND lastchange=".$time."
  166. AND supplytime=".$time."
  167. AND %prefix%food_product.id = %prefix%food_option.parentid
  168. AND %prefix%food_ordering.productid = %prefix%food_product.id
  169. AND %prefix%user.userid = %prefix%food_ordering.userid");
  170. //$dsp->AddDoubleRow('Ergebnis', $seat2->SeatOfUser($abfrage['userid'], 0, 2));
  171. $dsp->AddDoubleRow('Was -> Wohin', $abfrage['pice'].' x '.$abfrage['caption']. ' ('.$abfrage['unit']. ') -> '.$abfrage['username'].' ('.$abfrage['firstname'].' '.$abfrage['name'].') '.$seat2->SeatOfUser($abfrage['userid'], 0, 2));
  172. //change ende
  173. }elseif ($_GET["status"] == 8){
  174. $totprice = 0;
  175. $prodrow = $db->qry_first("SELECT * FROM %prefix%food_ordering WHERE id = %string%", $item);
  176. unset($account);
  177. $account = new accounting($prodrow['userid']);
  178. $price = 0;
  179. $tempdesc = "";
  180. if(stristr($prodrow['opts'],"/")){
  181. $values = explode("/",$prodrow['opts']);
  182. foreach ($values as $number){
  183. if(is_numeric($number)){
  184. $optrow = $db->qry_first("SELECT price, caption FROM %prefix%food_option WHERE id = %int%", $number);
  185. $price += $optrow['price'];
  186. $tempdesc .= $optrow['caption'];
  187. }
  188. }
  189. }else{
  190. $optrow = $db->qry_first("SELECT price, caption FROM %prefix%food_option WHERE id = %int%", $prodrow['opts']);
  191. $price += $optrow['price'];
  192. $tempdesc .= $optrow['caption'];
  193. }
  194. $totprice += $price * $prodrow['pice'];
  195. $tempsession = $_SESSION;
  196. $account->change( $totprice,
  197. t('Rόckzahlung bei abbestellten Produkten') . " (" . $auth['username'] . ") Artikel:".$tempdesc,
  198. $prodrow['userid']);
  199. $_SESSION = $tempsession;
  200. unset($tempsession);
  201. $db->qry_first("DELETE FROM %prefix%food_ordering WHERE id = %int%", $item);
  202. }else{
  203. $db->qry("UPDATE %prefix%food_ordering SET status = %string%, lastchange = %string% WHERE id = %string%", $_GET["status"], $time, $item);
  204. if($_GET["status"] == 3){
  205. $user_id = $db->qry_first("SELECT userid FROM %prefix%food_ordering WHERE id = %string%", $item);
  206. $func->setainfo(t('Deine bestellten Produkte sind abholbereit'),$user_id['userid'],2,"foodcenter",$item);
  207. }
  208. }
  209. }
  210. $fc_ordered_status_ask[4] = t('Produkte abbestellt');
  211. $fc_ordered_status_ask[5] = t('Status auf abgeholt gesetzt');
  212. $fc_ordered_status_ask[3] = t('Status auf Abholbereit gesetzt');
  213. $fc_ordered_status_ask[2] = t('Status auf bestellt gesetzt');
  214. $fc_ordered_status_ask[1] = t('Status auf bestellen gesetzt');
  215. $func->confirmation($fc_ordered_status_ask[$_GET["status"]],"index.php?mod=foodcenter&action=statchange");
  216. }else{
  217. $link_array[0] = "index.php?mod=foodcenter&action=statchange&step=3&id={$_GET['id']}&status=6";
  218. $link_array[1] = "index.php?mod=foodcenter&action=statchange&step=3&id={$_GET['id']}&status=5";
  219. $link_array[2] = "index.php?mod=foodcenter&action=statchange&step=3&id={$_GET['id']}&status=3";
  220. $link_array[3] = "index.php?mod=foodcenter&action=statchange&step=3&id={$_GET['id']}&status=7";
  221. $link_array[4] = "index.php?mod=foodcenter&action=statchange&step=3&id={$_GET['id']}&status=8";
  222. $link_array[5] = "index.php?mod=foodcenter&action=statchange";
  223. $func->multiquestion($fc_ordered_status_quest,$link_array,t('Status setzen'));
  224. }
  225. break;
  226. case 10:
  227. $dsp->NewContent(t('Produkt abbestellen'),t('Bitte wδhlen sie die Produktanzahl die abbestellt werden soll.'));
  228. $dsp->SetForm("index.php?mod=foodcenter&action=statchange&step=3&id={$_GET['id']}&status=4");
  229. $dsp->AddDropDownFieldRow("delcount",t('Anzahl'),$count_array,"");
  230. $dsp->AddFormSubmitRow(t('Weiter'));
  231. $dsp->AddContent();
  232. break;
  233. }