sadiq81

madplan.php

Aug 29th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.74 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>FoodPlaner</title>
  4.  
  5.  
  6.  
  7. <style type="text/css">
  8. .tal {
  9.     text-align: right;
  10. }
  11. </style>
  12.  
  13.  
  14. <script type="text/javascript">
  15. function getNewReceipe(categori, day)
  16. {
  17. if (categori=="")
  18.   {
  19.   return;
  20.   }
  21. if (window.XMLHttpRequest)
  22.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  23.   xmlhttp=new XMLHttpRequest();
  24.   }
  25. else
  26.   {// code for IE6, IE5
  27.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  28.   }
  29. xmlhttp.onreadystatechange=function()
  30.   {
  31.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  32.     {
  33.     document.getElementById(day).innerHTML=xmlhttp.responseText;
  34.     }
  35.   }
  36. xmlhttp.open("GET","newTable.php?q="+categori+"&day="+day,true);
  37. xmlhttp.send();
  38. }
  39. </script>
  40. </head>
  41. <body>
  42.  
  43. <?php
  44.  
  45. error_reporting ( 0 );
  46.  
  47. $including = true;
  48.  
  49. include ('helper.php');
  50.  
  51. ini_set ( 'default_charset', 'UTF-8' );
  52.  
  53. ?>
  54.  
  55. <center>
  56.  
  57.  
  58.  
  59. <h1>Kal kya pakaye.com</h1>
  60.  
  61. <script language="javascript" type="text/javascript">
  62.  
  63. function checkIfFeltIsTrue(felt){
  64.    
  65. if (felt[1].checked == true)
  66. {
  67.     return true;   
  68. }
  69. return false;
  70. }
  71.  
  72. </script>
  73.  
  74.  
  75. <?php
  76. if (! isset ( $_POST [ja] ) and ! isset ( $_POST ["vaelgOpskrifter"] ) and (! isset ( $_POST [lockweeksrecepies] ))) {
  77.     ?>
  78. <h2>Lets make our menu</h2>
  79.  
  80. <form name="chooseInterval" method="post" action="<?php print "$_SERVER[PHP_SELF]";?>">
  81.  
  82. What interval do you want your menu? <br>
  83. <br>
  84. <table>
  85.     <tr>
  86.         <td>Next week<input type="radio" name="interval" value="nextWeek" onclick="document.chooseInterval.includingToday.checked = false"></td>
  87.     </tr>
  88.     <tr>
  89.         <td>Rest of this week<input id="restOfThisWeek" type="radio" name="interval" value="restOfThisWeek">
  90.         Including today?<input id= "includingToday" type="checkbox" name="includingToday" onclick="return checkIfFeltIsTrue(document.chooseInterval.elements['interval'])"></td>
  91.     </tr>
  92.     <tr>
  93.         <!-- <td>Just today<input type="radio" name="interval" value="onlyToday"></td> -->
  94.     </tr>
  95. </table>
  96. <input type="submit" value="Lets do it!!!" name="ja">
  97. </form>
  98.  
  99. <?php
  100. }
  101.  
  102. if (isset ( $_POST [ja] )) {
  103.     ?>
  104.  
  105. <form method="post" action="<?php print "$_SERVER[PHP_SELF]";?>">
  106. <table border=1>
  107.     <tbody>
  108.         <tr>
  109.        
  110.         <?php
  111.    
  112.     $weekdaysPrint = array ("Monday", "Tuesday", "Wedensday", "Thursday", "Friday", "Saturday", "Sunday" );
  113.    
  114.     $dayOfTheWeek = 0;
  115.    
  116.     if ($_POST [interval] == "restOfThisWeek") {
  117.         $dayOfTheWeek = ( integer ) date ( "w", time () );
  118.        
  119.         if (isset ( $_POST [includingToday] )) {
  120.             $dayOfTheWeek -= 1;
  121.         }
  122.     }
  123.    
  124.     if ($_POST [interval] == "onlyToday") {
  125.         $dayOfTheWeek = 6;
  126.         $weekdaysPrint [6] = "Today";
  127.     }
  128.    
  129.     for($optaelling1 = $dayOfTheWeek; $optaelling1 < 7; $optaelling1 ++)
  130.  
  131.     {
  132.         print ("<th>") ;
  133.         print $weekdaysPrint [$optaelling1];
  134.         print ("</th>") ;
  135.     }
  136.    
  137.     ?>
  138.         </tr>
  139.         <tr>
  140.  
  141. <?php
  142.    
  143.     $receipeCategories = array ("Rice with chicken", "Roti with ghost", "Roti with chicken", "Rice with ghost", "Other", "Weekend", "Day Off" );
  144.     $weekdays = array ("monday", "tuesday", "wedensday", "thursday", "friday", "saturday", "sunday" );
  145.    
  146.     for($optaelling = $dayOfTheWeek; $optaelling < 7; $optaelling ++)
  147.     {
  148.         print ("<th>") ;
  149.        
  150.         print ("<select name=\"$weekdays[$optaelling]\">") ;
  151.        
  152.         for($count = 0; $count < 7; $count ++) {
  153.            
  154.             print ("<option value=\"" . $receipeCategories [$count]) ;
  155.             if ($optaelling == $count)
  156.             {
  157.                 print ("\" SELECTED ") ;
  158.             }
  159.             print ("\">" . $receipeCategories [$count]) ;
  160.             print ("</option>") ;
  161.             print ("\n") ;
  162.         }
  163.         print ("</select>") ;
  164.         print ("\n") ;
  165.         print ("</th>") ;
  166.     }
  167.     ?>
  168. </tr>
  169.     </tbody>
  170. </table>
  171. <br>
  172. <input type="hidden" name="interval" value="<?php print ($_POST [interval]) ;?>">
  173. <input type="hidden" name="includingToday" value="<?php print ($_POST [includingToday]) ;?>">
  174. <input type="submit" value="ok" name="vaelgOpskrifter">
  175. <br>
  176. <br>
  177. <input type="button" value="Change your choice" onclick="history.go(-1);return false;" /></form>
  178. <?php
  179. }
  180. ?>
  181.  
  182. <?php
  183. if (isset ( $_POST [vaelgOpskrifter] )) {
  184.    
  185.     $weeksrecepies = array ($_POST [monday], $_POST [tuesday], $_POST [wedensday], $_POST [thursday], $_POST [friday], $_POST [saturday], $_POST [sunday] );
  186.    
  187.     if (in_array ( "Rice with chicken", $weeksrecepies )) {
  188.         $Rice_with_chickenArray = getRiceWithChickenArray ();
  189.         shuffle ( $Rice_with_chickenArray );
  190.     }
  191.    
  192.     if (in_array ( "Rice with ghost", $weeksrecepies )) {
  193.         $Rice_with_ghostArray = getRiceWithGhostArray ();
  194.         shuffle ( $Rice_with_ghostArray );
  195.     }
  196.    
  197.     if (in_array ( "Roti with chicken", $weeksrecepies )) {
  198.         $Roti_with_chickenArray = getRotiWithChickenArray ();
  199.         shuffle ( $Roti_with_chickenArray );
  200.     }
  201.    
  202.     if (in_array ( "Roti with ghost", $weeksrecepies )) {
  203.         $Roti_with_ghostArray = getRotiWithGhostArray ();
  204.         shuffle ( $Roti_with_ghostArray );
  205.     }
  206.    
  207.     if (in_array ( "Other", $weeksrecepies )) {
  208.         $OtherArray = getOtherArray ();
  209.         shuffle ( $OtherArray );
  210.     }
  211.    
  212.     if (in_array ( "Weekend", $weeksrecepies )) {
  213.         $WeekendArray = getWeekendArray ();
  214.         shuffle ( $WeekendArray );
  215.     }
  216.    
  217.     if (in_array ( "Day Off", $weeksrecepies )) {
  218.         $DayOffArray = Array(" ", " ", " ", " ", " "," "," ");
  219.        
  220.     }
  221.    
  222.  
  223.     ?>
  224.    
  225.  
  226. <table border=1 width="600">
  227.     <tbody>
  228.         <tr>
  229.             <th align="center" width="20%">Day to cook</th>
  230.             <th align="center" width="20%">Type of Dish</th>
  231.             <th align="center" width="20%">Name of Dish</th>
  232.             <th align="center" width="20%">Last made</th>
  233.             <th align="center" width="20%">&nbsp;</th>
  234.         </tr>
  235. </table>
  236.  
  237. <?php
  238.    
  239.     if (($_POST [interval]) != "onlyToday")
  240.  
  241.     {
  242.         ?>
  243.  
  244. <form method="post" action="<?php print "$_SERVER[PHP_SELF]"?>">
  245. <div id="mondayTable">
  246. <table border=1 width="600">
  247.         <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
  248.             <th align="left" width="20%">Monday:&nbsp;</th>
  249.             <th align="left" width="20%"><?php print ($_POST [monday]);?>&nbsp;</th>
  250.             <th align="left" width="20%"><?php $mondayArray = ($_POST [monday]);
  251.                            
  252.                 $mondayArray = str_replace ( " ", "_", $mondayArray );
  253.  
  254.                 $mondaysdish = array_pop ( ${$mondayArray . 'Array'} );
  255.                
  256.                 print ($mondaysdish ['name']) ; ?>&nbsp;</th>
  257.                
  258.             <th align="left" width="20%"><?php print ($mondaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?>&nbsp;</th>
  259.             <?php
  260.             if ($mondaysdish != null)
  261.             {
  262.             ?>
  263.             <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [monday]);?>','mondayTable')">&nbsp;</th>
  264.             <?php
  265.             }
  266.             if ($mondaysdish == null)
  267.             {
  268.             ?>
  269.             <th align="left" width="20%">&nbsp;</th>
  270.             <?php
  271.             }
  272.             ?>
  273.         </tr>
  274. </table>
  275. <input type="hidden" value="<?php print ($mondaysdish ['name']);?>" name="monday">
  276. <input type="hidden" value="<?php print ($_POST[monday]);?>" name="mondayCategori">
  277. </div>     
  278.  
  279. <div id="tuesdayTable">
  280. <table border=1 width="600">
  281.         <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
  282.             <th align="left" width="20%">Tuesday:&nbsp;</th>
  283.             <th align="left" width="20%"><?php print ($_POST [tuesday]) ;?>&nbsp;</th>
  284.             <th align="left" width="20%"><?php $tuesdayArray = ($_POST [tuesday]);
  285.                
  286.                 $tuesdayArray = str_replace ( " ", "_", $tuesdayArray );
  287.                
  288.                 $tuesdaysdish = array_pop ( ${$tuesdayArray . 'Array'} );
  289.                
  290.                 print ($tuesdaysdish ['name']) ;?>&nbsp;</th>
  291.             <th align="left" width="20%"> <?php print ($tuesdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;  ?>&nbsp;</th>
  292.             <?php
  293.             if ($tuesdaysdish != null)
  294.             {
  295.             ?>
  296.             <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [tuesday]);?>','tuesdayTable')">&nbsp;</th>
  297.             <?php
  298.             }
  299.             if ($tuesdaysdish == null)
  300.             {
  301.             ?>
  302.             <th align="left" width="20%">&nbsp;</th>
  303.             <?php
  304.             }
  305.             ?>     
  306.         </tr>
  307. </table>
  308. <input type="hidden" value="<?php print ($tuesdaysdish ['name']);?>" name="tuesday">
  309. <input type="hidden" value="<?php print ($_POST[tuesday]);?>" name="tuesdayCategori">
  310. </div>
  311. <div id="wedensdayTable">
  312. <table border=1 width="600">
  313.         <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
  314.             <th align="left" width="20%">Wedensday:&nbsp;</th>
  315.             <th align="left" width="20%"><?php print ($_POST [wedensday]) ;?>&nbsp;</th>
  316.             <th align="left" width="20%"><?php $wedensdayArray = ($_POST [wedensday]);
  317.                
  318.                 $wedensdayArray = str_replace ( " ", "_", $wedensdayArray );
  319.                
  320.                 $wedensdaysdish = array_pop ( ${$wedensdayArray . 'Array'} );
  321.                
  322.                 print ($wedensdaysdish ['name']) ;?>&nbsp;</th>
  323.             <th align="left" width="20%"><?php print ($wedensdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ; ?>&nbsp;</th>
  324.             <?php
  325.             if ($wedensdaysdish != null)
  326.             {
  327.             ?>
  328.             <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [wedensday]);?>','wedensdayTable')">&nbsp;</th>
  329.             <?php
  330.             }
  331.             if ($wedensdaysdish == null)
  332.             {
  333.             ?>
  334.             <th align="left" width="20%">&nbsp;</th>
  335.             <?php
  336.             }
  337.             ?>
  338.         </tr>
  339. </table>
  340. <input type="hidden" value="<?php print ($wedensdaysdish ['name']);?>" name="wedensday">
  341. <input type="hidden" value="<?php print ($_POST[wedensday]);?>" name="wedensdayCategori">
  342. </div>
  343. <div id="thursdayTable">
  344. <table border=1 width="600">
  345.         <tr onmouseover="style.background='#C0C0C0'"    onmouseout="style.background='white'">
  346.             <th align="left" width="20%">Thursday:&nbsp;</th>
  347.             <th align="left" width="20%"><?php print ($_POST [thursday]) ; ?>&nbsp;</th>
  348.             <th align="left" width="20%"><?php $thursdayArray = ($_POST [thursday]);
  349.                            
  350.                 $thursdayArray = str_replace ( " ", "_", $thursdayArray );
  351.            
  352.                 $thursdaysdish = array_pop ( ${$thursdayArray . 'Array'} );
  353.                
  354.                 print ($thursdaysdish ['name']) ;?>&nbsp;</th>
  355.             <th align="left" width="20%"> <?php print ($thursdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ; ?>&nbsp;</th>
  356.             <?php
  357.             if ($thursdaysdish != null)
  358.             {
  359.             ?>
  360.             <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [thursday]);?>','thursdayTable')">&nbsp;</th>
  361.             <?php
  362.             }
  363.             if ($thursdaysdish == null)
  364.             {
  365.             ?>
  366.             <th align="left" width="20%">&nbsp;</th>
  367.             <?php
  368.             }
  369.             ?>
  370.         </tr>
  371. </table>
  372. <input type="hidden" value="<?php print ($thursdaysdish ['name']);?>" name="thursday">
  373. <input type="hidden" value="<?php print ($_POST[thursday]);?>" name="thursdayCategori">
  374. </div>
  375. <div id="fridayTable">
  376. <table border=1 width="600">
  377.         <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
  378.             <th align="left" width="20%">Friday:&nbsp;</th>
  379.             <th align="left" width="20%"><?php print ($_POST [friday]) ;    ?>&nbsp;</th>
  380.             <th align="left" width="20%"><?php $fridayArray = ($_POST [friday]);
  381.  
  382.                 $fridayArray = str_replace ( " ", "_", $fridayArray );
  383.                
  384.                 $fridaysdish = array_pop ( ${$fridayArray . 'Array'} );
  385.                
  386.                 print ($fridaysdish ['name']) ; ?>&nbsp;</th>
  387.             <th align="left" width="20%"><?php print ($fridaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?>&nbsp;</th>
  388.             <?php
  389.             if ($fridaysdish != null)
  390.             {
  391.             ?>
  392.             <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [friday]);?>','fridayTable')">&nbsp;</th>
  393.             <?php
  394.             }
  395.             if ($fridaysdish == null)
  396.             {
  397.             ?>
  398.             <th align="left" width="20%">&nbsp;</th>
  399.             <?php
  400.             }
  401.             ?>
  402.         </tr>
  403. </table>
  404. <input type="hidden" value="<?php print ($fridaysdish ['name']);?>" name="friday">
  405. <input type="hidden" value="<?php print ($_POST[friday]);?>" name="fridayCategori">
  406. </div>
  407. <div id="saturdayTable">
  408. <table border=1 width="600">
  409.         <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
  410.             <th align="left" width="20%">Saturday:&nbsp;</th>
  411.             <th align="left" width="20%"><?php print ($_POST [saturday]) ;?>&nbsp;</th>
  412.             <th align="left" width="20%"><?php $saturdayArray = ($_POST [saturday]);
  413.                
  414.                 $saturdayArray = str_replace ( " ", "_", $saturdayArray );
  415.                
  416.                 $saturdaysdish = array_pop ( ${$saturdayArray . 'Array'} );
  417.                
  418.                 print ($saturdaysdish ['name']) ;?>&nbsp;</th>
  419.             <th align="left" width="20%"><?php print ($saturdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;?>&nbsp;</th>
  420.             <?php
  421.             if ($saturdaysdish != null)
  422.             {
  423.             ?>
  424.             <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [saturday]);?>','saturdayTable')">&nbsp;</th>
  425.             <?php
  426.             }
  427.             if ($saturdaysdish == null)
  428.             {
  429.             ?>
  430.             <th align="left" width="20%">&nbsp;</th>
  431.             <?php
  432.             }
  433.             ?>
  434.         </tr>
  435. </table>
  436. <input type="hidden" value="<?php print ($saturdaysdish ['name']);?>" name="saturday">
  437. <input type="hidden" value="<?php print ($_POST[saturday]);?>" name="saturdayCategori">
  438. </div>
  439. <div id="sundayTable">
  440. <table border=1 width="600">
  441.         <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
  442.             <th align="left" width="20%">Sunday:&nbsp;</th>
  443.             <th align="left" width="20%"><?php print ($_POST [sunday]) ;    ?>&nbsp;</th>
  444.             <th align="left" width="20%"><?php $sundayArray = ($_POST [sunday]);
  445.        
  446.             $sundayArray = str_replace ( " ", "_", $sundayArray );
  447.                
  448.             $sundaysdish = array_pop ( ${$sundayArray . 'Array'} );
  449.                
  450.             print ($sundaysdish ['name']) ; ?>&nbsp;</th>
  451.             <th align="left" width="20%"><?php print ($sundaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?>&nbsp;</th>
  452.             <?php
  453.             if ($sundaysdish != null)
  454.             {
  455.             ?>
  456.             <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [sunday]);?>','sundayTable')">&nbsp;</th>
  457.             <?php
  458.             }
  459.             if ($sundaysdish == null)
  460.             {
  461.             ?>
  462.             <th align="left" width="20%">&nbsp;</th>
  463.             <?php
  464.             }
  465.             ?>
  466.         </tr>
  467. </table>
  468. <input type="hidden" value="<?php print ($sundaysdish ['name']);?>" name="sunday">
  469. <input type="hidden" value="<?php print ($_POST[sunday]);?>" name="sundayCategori">
  470. </div>
  471. <input type="button" value=" &lt;-- Choose other recepies " onclick="history.go(-1);return false;" />
  472. <br>
  473. <br>
  474. <input type="submit" name="lockweeksrecepies" value="Lock Recepies" onmouseover="this.value='Recepies will be locked for 3 weeks!'" onmouseout="this.value='Lock Recepies'">
  475. </form>
  476.  
  477.  
  478. <br>
  479. <br>
  480.  
  481.  
  482.  
  483.  
  484.  
  485. <?php
  486.     }
  487. }
  488.  
  489. if (isset ( $_POST [lockweeksrecepies] )) {
  490.    
  491.     $message = '<html><body>';
  492.     $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
  493.     $message .= "<tr style='background: #eee;'><td><strong>Day</strong></td><td><strong>Categori</strong></td><td><strong>Dish</strong></td></tr>";
  494.     $message .= "<tr><td>Monday:</td><td>".$_POST[mondayCategori]."</td><td>".$_POST[monday]."</td></tr>";
  495.     $message .= "<tr><td>Tuesday:</td><td>".$_POST[tuesdayCategori]."</td><td>".$_POST[tuesday]."</td></tr>";
  496.     $message .= "<tr><td>Wedensday:</td><td>".$_POST[wedensdayCategori]."</td><td>".$_POST[wedensday]."</td></tr>";
  497.     $message .= "<tr><td>Thursday:</td><td>".$_POST[thursdayCategori]."</td><td>".$_POST[thursday]."</td></tr>";
  498.     $message .= "<tr><td>Friday:</td><td>".$_POST[fridayCategori]."</td><td>".$_POST[friday]."</td></tr>";
  499.     $message .= "<tr><td>Saturday:</td><td>".$_POST[saturdayCategori]."</td><td>".$_POST[saturday]."</td></tr>";
  500.     $message .= "<tr><td>Sunday:</td><td>".$_POST[sundayCategori]."</td><td>".$_POST[sunday]."</td></tr>";
  501.     $message .= "</table>";
  502.     $message .= "</body></html>";
  503.    
  504. //  $headers = "From: Foodplaner\r\n";
  505.     $headers .= "MIME-Version: 1.0\r\n";
  506.     $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  507.        
  508.     mail("[email protected]", "Weekmenu", $message, $headers);
  509.    
  510.     //  weekMenuApproved($_POST[monday], $_POST[tuesday], $_POST[wedensday], $_POST[thursday], $_POST[friday], $_POST[saturday], $_POST[sunday]);
  511.    
  512.  
  513.     print ("Receipes locked!") ;
  514.     print ("<br>") ;
  515.     print ("<br>") ;
  516.     print ("Check apka email for menu") ;
  517.     print("<br>");
  518.     print("<br>");
  519.  
  520. }
  521. ?>
  522. </center>
  523. </body>
  524. </html>
Advertisement
Add Comment
Please, Sign In to add comment