linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file add.php

Documentation is available at add.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage dashboard
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. //////////// Check Inclusion de pages ////////////
  12. if (!class_exists('auth')){
  13.   include_once("../lib/lib_common.php");
  14.   ReloadIndex('admin');
  15. }
  16. ////////////
  17.  
  18. //////////// Check Droits utilisateur ////////////
  19. if (!$l21auth->hasRight('dashboard')) ReloadIndex('admin');
  20. ////////////
  21.  
  22. include_once("../lib/input_helpers.php");
  23. if(!isset($_GET['id']&& !isset($_POST['id'])) {
  24.   $id=1;
  25. else {
  26.   if(isset($_POST['id']))    $id=$_POST['id'];
  27.   if(isset($_GET['id']))    $id=$_GET['id'];
  28. }
  29. if(!isset($_GET['scale_id']&& !isset($_POST['scale_id'])) {
  30.   $scale_id=1;
  31. else {
  32.   if(isset($_POST['scale_id']))    $scale_id=$_POST['scale_id'];
  33.   if(isset($_GET['scale_id']))    $scale_id=$_GET['scale_id'];
  34. }
  35.  
  36.  
  37. $link_mod_sdi="index.php?&amp;rub=sdi&amp;todo=det&amp;id=";
  38. $link_cancel=$rub_link."&amp;todo=det&amp;id=".$id."&amp;scale_id=".$scale_id;
  39.  
  40. if (isset($_POST['enregistrer'])) {
  41.   $data_table unserialize(urldecode($_POST['data_table']));
  42.   $sdi_objectnew sdi;
  43.   $result=$sdi_object->AddValue($data_table$sql_object);
  44.   $link_confirm="confirm.php?rub=".$rub."&todo=".$todo."&id=".$id."&scale_id=".$scale_id;
  45.   if(isset($result)) header("Location: ".$link_confirm);
  46.   else  system_error();
  47. }
  48. $form_value ="";
  49. $form_sdi_id ="";
  50. $form_scale_id $scale_id;
  51. $form_date ="";
  52. $form_threshold ="";
  53. $form_statut "";
  54. $mask_statut_P="checked=\"checked\"";
  55. $mask_statut_D='';
  56. $form_comment "";
  57. $mask_statutc_public="checked=\"checked\"";
  58. $mask_statutc_private='';
  59.  
  60. $resultscale $sql_object -> DBSelect($req_list_scale);
  61. $listing=ScaleSelectBox($resultscale"scale" ,$form_scale_id;
  62.  
  63. $sdi_objectnew sdi;
  64. $req_sdii=SQL_getInfoSdi($id);
  65. $result_sdii $sql_object -> DBSelect($req_sdii);
  66.  
  67. $req_sdiav=SQL_getAllValue("SCA"$scale_id$id);
  68. $result_value $sql_object -> DBSelect($req_sdiav);
  69.  
  70. $navtitle=_t('dashboard','add')." : ".$result_sdii[0]['sdii_name'];
  71.  
  72. // setting $form_threshold value
  73. // By default initial value
  74. $default_threshold $result_sdii[0]['sdii_threshold_value'];
  75. // if set, we get the latest for the given scale
  76. $r $sql_object -> DBSelect(SQL_getlastInsertByPublicationDate($id$scale_id));
  77.  
  78. if(isset($r[0]['sdiv_value']&& !is_null($r[0]['sdiv_threshold'])) {
  79.     $form_threshold $r[0]['sdiv_threshold'];
  80. else {
  81.     $form_threshold $default_threshold;
  82. }
  83.  
  84. if (isset($_POST['valider1'])) {
  85.  
  86.   $table[0$_POST['value'];
  87.   $table[1$_POST['id'];
  88.   $table[2$_POST['threshold'];
  89.   $table[3$_POST['scale'];
  90.   $table[4$_POST['date'];
  91.   $table[5$_POST['statut'];
  92.   $table[6$_POST['comment'];
  93.   $table[7$_POST['statutc'];
  94.   $sdi_object new sdi;
  95.   $integrity $sdi_object -> CheckDataIntegrity_value($table$sql_object);
  96.   $form_value =$_POST['value'];
  97.   $form_sdi_id =$_POST['id'];
  98.   $form_threshold $_POST['threshold'];
  99.   $form_scale_id =$_POST['scale'];
  100.   $form_date =$_POST['date'];
  101.   $form_statut $_POST['statut'];
  102.   $form_statutc $_POST['statutc'];
  103.   if($form_statut=='D'$mask_statut_D="checked=\"checked\""else $mask_statut_D='';
  104.   if($form_statut=='P'$mask_statut_P="checked=\"checked\""else $mask_statut_P='';
  105.   if($form_statutc=='Y'$mask_statutc_public="checked=\"checked\""else $mask_statutc_public='';
  106.   if($form_statutc=='N'$mask_statutc_private="checked=\"checked\""else $mask_statutc_private='';
  107.   $table urlencode(serialize($table));
  108. }
  109.  
  110. include_once(THEME_ADMIN_PATH."quickicons.php");
  111.  
  112.  
  113.  
  114. footerAddJS('../lib/js/jquery.datePicker.l10n/jquery.ui.datepicker-'.U_L.'.js');
  115. ?>
  116. <div id="chemin">
  117.   <ul>
  118.       <li><a href="index.php" class="chemin_home"><?php echo _t('way','home')?></a></li>
  119.       <li><a href="<?php echo $rub_link?>" id="chemin_<?php echo $rub?>"    class="chemin_rub"><?php echo _t('menu','dashboard');?></a></li>
  120.       <li><span><?php echo formatnavTitle($navtitle)?></span></li>
  121.   </ul>
  122. </div>
  123. <!--end barre haute -->
  124.  
  125. <script type="text/javascript">    
  126.     $(function()
  127.     {
  128.         var dateFormat = "<?php echo DATE_FORMAT?>";
  129.         dateFormat = dateFormat.replace("yyyy", "yy");
  130.         
  131.         $(".date-pick").datepicker({
  132.             showOn: "button",
  133.             buttonImage: "../lib/js/calendar.png",
  134.             buttonImageOnly: true,
  135.             dateFormat: dateFormat,
  136.             dateMin: new Date(2000, 1 - 1, 1)
  137.         });
  138.         $( ".date-pick" ).datepicker( $.datepicker.regional[ "<?php echo U_L?>" ] );
  139.  
  140.         var thresholds = <?php echo json_encode($sdi_object->getScalesThresholds($id$default_threshold$sql_object))?>;
  141.  
  142.         // update threshold value when changing scale
  143.         $('#scale').change(function() {
  144.               var key = $("#scale").val()
  145.               $("#threshold").val(thresholds[key]);
  146.             });
  147.         
  148.     });
  149. </script>
  150.  
  151. <?php
  152. if (!isset($integrity|| is_string($integrity)) {
  153. ?>
  154. <div class="contentcontainer">
  155. <?php
  156. include_once(override($dir.'/menurub.php'THEME_ADMIN_PATH));
  157. ?>
  158. <div id="content">
  159. <?php
  160. if (isset($integrity&& is_string($integrity)) display_errors($integrity);
  161.  
  162. if ($l21auth->isSuperAdmin()){?>
  163. <div class="mod_link"><a href="<?php echo $link_mod_sdi.$id ;?>"><?php echo mb_ucfirst(_t('dashboard','det_sdi'));?></a>
  164. </div>
  165. <br class="brendstep" />
  166. <?php ?>
  167. <h2><?php echo mb_ucfirst(_t('dashboard','add_title1'))?></h2>
  168.  
  169. <form id="addvalue" action="<?php echo $_SERVER['SCRIPT_NAME']?>"    method="post">
  170. <p>
  171.     <label for="value"><?php echo mb_ucfirst(_t('dashboard','value')) ?> (<?php echo $result_sdii[0]['sdii_unit']?>): *</label>
  172.     <input name="value" type="text" id="value" maxlength="255" value="<?php echo $form_value?>" class="textfield" />
  173. </p>
  174. <p>
  175.     <label for="scale"><?php echo mb_ucfirst(_t('dashboard','scale')) ?> : *</label>
  176.     <?php echo $listing?>
  177. </p>
  178. <p>
  179.     <label for="threshold"><?php echo mb_ucfirst(_t('sdi','threshold_value')) ?> :</label>
  180.     <input name="threshold" type="text" id="threshold" maxlength="100" value="<?php echo $form_threshold?>" class="textfield" />
  181. </p>
  182. <div class="label"><?php echo mb_ucfirst(_t('divers','statut'))?> : *</div>
  183. <div class="rightpanel">
  184.     <input name="statut" type="radio" id="statut_P" value="P" <?php echo $mask_statut_P?> />
  185.     <label for="statut_P"><?php echo mb_ucfirst(_t('statut','public'))?></label>
  186.     <input name="statut" type="radio" id="statut_D" value="D" <?php echo $mask_statut_D?> />
  187.     <label for="statut_D"><?php echo mb_ucfirst(_t('statut','draft'))?></label>
  188. </div>
  189. <p>
  190.     <label for="date"><?php echo mb_ucfirst(_t('dashboard','date'))?> : *</label>
  191.     <input name="date" type="text" maxlength="10" id="date"    class="date-pick shorttextfield" value="<?php echo $form_date?>" />
  192. </p>
  193. <p>
  194.     <label for="comment"><?php echo mb_ucfirst(_t('dashboard','comment')) ?> : </label> 
  195.     <textarea id="comment" name="comment" <?php echo AREA_SETTINGS?>    class="largetextfield"><?php echo $form_comment?></textarea>
  196. </p>
  197. <div class="label"><?php echo mb_ucfirst(_t('dashboard','comment_status'))?> * : </div>
  198. <div class="rightpanel">
  199.     <input name="statutc" type="radio" id="statutc_P" value="Y" <?php echo $mask_statutc_public?> />
  200.     <label for="statutc_P"><?php echo mb_ucfirst(_t('dashboard','public'))?></label>
  201.     <input name="statutc" type="radio" id="statutc_D" value="N" <?php echo $mask_statutc_private?> />
  202.     <label for="statutc_D"><?php echo mb_ucfirst(_t('dashboard','private'))?></label>
  203. </div>
  204. <div class="toggle_title">
  205.     <a href="#" id="affeval"><?php echo _t('sdi','info_mesure');?></a>
  206. </div>
  207. <div id="evaluation" style="display: none;"><br class="brendstep" />
  208. <table cellspacing="0" cellpadding="3">
  209.     <thead>
  210.         <tr>
  211.         <?php
  212.         echo "<td>".mb_ucfirst(_t('sdi','unit'))."</td>\n";
  213.         echo "<td>".mb_ucfirst(_t('sdi','min_value'))."</td>\n";
  214.         echo "<td>".mb_ucfirst(_t('sdi','max_value'))."</td>\n";
  215.         echo "<td>".mb_ucfirst(_t('sdi','initial_threshold_value'))."</td>\n";
  216.         ?>
  217.         </tr>
  218.     </thead>
  219.     <tbody>
  220.     <?php echo "<tr>\n";
  221.     echo "<td>"$result_sdii[0]['sdii_unit']."</td>\n";
  222.     echo "<td>"empty_nc($result_sdii[0]['sdii_min_value'])."</td>\n";
  223.     echo "<td>"empty_nc($result_sdii[0]['sdii_max_value'])."</td>\n";
  224.     echo "<td>"empty_nc($result_sdii[0]['sdii_threshold_value'])."</td>\n";
  225.     echo "</tr>\n";
  226.     ?>
  227.     </tbody>
  228. </table>
  229. </div>
  230.     <?php if ($result_value<>false{?>
  231. <div class="toggle_title">
  232.     <a href="#" id="affval"><?php echo _t('dashboard','all_value');?></a>
  233. </div>
  234. <div id="valeur" style="display: none;"><br class="brendstep" />
  235. <table cellspacing="0" cellpadding="3">
  236.     <thead>
  237.         <tr>
  238.         <?php
  239.         echo "<td>".mb_ucfirst(_t('dashboard','date'))."</td>\n";
  240.         echo "<td>".mb_ucfirst(_t('dashboard','value'))." (".formatText($result_sdii[0]['sdii_unit']'2HTML').")"."</td>\n";
  241.         echo "<td>".mb_ucfirst(_t('dashboard','comment'))."</td>\n";
  242.         ?>
  243.         </tr>
  244.     </thead>
  245.     <tbody>
  246.     <?php
  247.  
  248.     for ($i=0;$i<count($result_value);$i++){
  249.       
  250.       $comment '';
  251.       ($result_value[$i]['sdiv_comment_display'== 'Y'$comment_status _t('dashboard''public'$comment_status _t('dashboard''private');
  252.       if(!empty($result_value[$i]['sdiv_comment'])) {
  253.           $comment  '<div class="valuecomment">';
  254.           $comment .= '<img src="'.THEME_ADMIN_PATH.'images/infobull.gif" />';
  255.           $comment .= '<div class="cont"><strong>'.ucfirst(_t('dashboard''comment')).' ('.$comment_status.') :</strong> '.$result_value[$i]['sdiv_comment'].'</div>';
  256.           $comment .= '</div>';
  257.       }
  258.       
  259.       echo "<tr>\n";
  260.       echo "<td>"formatText($result_value[$i]['date_p']'2HTML')."</td>\n";
  261.       echo "<td>"formatText($result_value[$i]['sdiv_value']'2HTML');
  262.       if ($result_value[$i]['sdiv_statut']=='D'{
  263.         echo "<span class=\"state\">"._t('statut','draft')."</span>";
  264.       }
  265.       echo "</td>\n";
  266.       echo "<td>"$comment."</td>\n";
  267.       echo "</tr>\n";
  268.  
  269.     }
  270.     ?>
  271.     </tbody>
  272. </table>
  273.     <?php }
  274.     else echo "<div class=\"info\">"._t('dashboard','novalue');
  275.     ?></div>
  276.  
  277.   <div>
  278.     <input name="id" type="hidden" value="<?php echo $id?>" id="id" />
  279.     <input name="scale_id" type="hidden" value="<?php echo $scale_id?>" id="scale_id" />
  280.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  281.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  282.     <?php echo cancel_button($link_cancel)?>
  283.     <input name="valider1" type="submit" value="<?php echo _t('btn','valid'?>" class="button" id="valider" />
  284.   </div>
  285. </form>
  286. </div>
  287.     <?php include_once(override($dir.'/help.php'THEME_ADMIN_PATH))?></div>
  288.     <?php
  289.     // Récapitulatif
  290.     else {
  291.       if (!isset($integrity5|| is_string($integrity5)) {
  292.  
  293.  
  294.         $table=unserialize(urldecode($table));
  295.         $recap_nc _t('divers','none');
  296.         function empty_form($var$recap_nc)
  297.         {
  298.           if (empty($var)) $var2 $recap_nc;
  299.           else $var2 $var;
  300.           return $var2;
  301.         }
  302.  
  303.         $req_scale=SQL_getonescale($table[3]);
  304.         $resultscale2 $sql_object -> DBSelect($req_scale);
  305.  
  306.         $display_comment formatText(empty_none($_POST['comment'])'2HTML');
  307.         
  308.         ($form_statutc == 'Y'$display_comment_status _t('dashboard''public'$display_comment_status _t('dashboard''private');
  309.       
  310.         $display_sdi_value $table[0];
  311.         $display_threshold_value empty_nc($table[2]);
  312.         //afficher nom de scale
  313.         $display_sdi_scale formatText($resultscale2[0]['scale_denomination']'2HTML');
  314.         $display_sdi_date $table[4];
  315.         $display_sdi_statut$table[5];
  316.         $table urlencode(serialize($table));
  317. ?>
  318.  
  319. <div class="contentcontainer">
  320. <?php
  321. include_once(override($dir.'/menurub.php'THEME_ADMIN_PATH));
  322.  
  323. ?>
  324. <div id="content">
  325. <h2><?php echo _t('recap','title';
  326. ?></h2>
  327. <dl class="summary">
  328.     <dt><?php echo mb_ucfirst(_t('dashboard','value'))?> :</dt>
  329.     <dd><?php echo $display_sdi_value." ".$result_sdii[0]['sdii_unit']  ;
  330.     ?></dd>
  331.     <dt><?php echo mb_ucfirst(_t('sdi','name2'))?> :</dt>
  332.     <dd><?php echo formatText($result_sdii[0]['sdii_name']'2HTML')?></dd>
  333.     <dt><?php echo mb_ucfirst(_t('divers','statut'))?> :</dt>
  334.     <dd><?php echo display_statut($display_sdi_statut)?></dd>
  335.     <dt><?php echo mb_ucfirst(_t('dashboard','date'))?> :</dt>
  336.     <dd><?php echo $display_sdi_date ;?></dd>
  337.     <dt><?php echo mb_ucfirst(_t('dashboard','scale')) ;?> :</dt>
  338.     <dd><?php echo $display_sdi_scale ;?></dd>
  339.     <dt><?php echo mb_ucfirst(_t('dashboard','threshold_value'));    ?> :</dt>
  340.     <dd><?php echo $display_threshold_value;    ?></dd>
  341.     <dt><?php echo mb_ucfirst(_t('dashboard','comment')) ;?> :</dt>
  342.     <dd><?php echo $display_comment ;?></dd>
  343.     <dt><?php echo mb_ucfirst(_t('dashboard','comment_status')) ;?> :</dt>
  344.     <dd><?php echo $display_comment_status ;?></dd>
  345. </dl>
  346. <form id="addvalue2" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
  347.     <div>
  348.     <input name="rub" type="hidden" value="<?php echo $rub?>" id="rub" />
  349.     <input name="todo" type="hidden" value="<?php echo $todo?>" id="todo" />
  350.     <input name="id" type="hidden" value="<?php echo $id?>" id="id" />
  351.     <input name="scale_id" type="hidden" value="<?php echo $scale_id?>" id="scale_id" />
  352.     <input name="data_table" type="hidden" value="<?php echo $table?>" id="data_table" />
  353.     <?php echo cancel_button($link_cancel)?>
  354.     <input name="retour" type="button" value="<?php echo _t('btn','preview'?>" class="button" id="retour" onclick="history.go(-1);" />
  355.     <input name="enregistrer" type="submit" value="<?php echo _t('btn','save'?>" class="button" id="valider" />
  356.   </div>
  357. </form>
  358. </div>
  359. <?php include_once(override($dir.'/help.php'THEME_ADMIN_PATH))?>
  360. </div>
  361. <?php
  362.       }
  363.     }
  364. ?>
  365.     
  366. <script type="text/javascript">
  367. $(document).ready(function() {
  368.     $(".valuecomment").hover(
  369.         function() {
  370.             $('.cont', this).fadeIn();
  371.         },
  372.         function() {
  373.             $('.cont', this).hide();
  374.         }
  375.     );
  376. })
  377. </script>

Documentation generated on Thu, 20 Mar 2014 16:45:48 +0100 by phpDocumentor 1.4.1