Advertisement
hungaudi

Sales_generator reports v

Dec 28th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.73 KB | None | 0 0
  1. <?php $this->load->view("partial/header"); ?>
  2. <div id="content_area_wrapper">
  3. <div id="content_area">
  4. <div id="title_bar_newone">
  5.     <img style="width: 22px;height: 22px;margin: 11px;float: left" src='<?php echo base_url()?>images/menubar/reports.png' alt='<?php echo lang('reports_reports'); ?> - <?php echo lang('reports_welcome_message'); ?>' />
  6.     <?php echo $title ?>
  7. </div>
  8. <br />
  9.  
  10. <script type="text/javascript">
  11. (function($)
  12. {
  13.     $.fn.tokenize = function(options)
  14.     {
  15.         var settings = $.extend({}, {prePopulate: false}, options);
  16.         return this.each(function()
  17.         {
  18.             $(this).tokenInput('<?php echo site_url("reports/sales_generator"); ?>?act=autocomplete',
  19.             {
  20.                 theme: "facebook",
  21.                 queryParam: "term",
  22.                 extraParam: "w",
  23.                 hintText: <?php echo json_encode(lang("reports_sales_generator_autocomplete_hintText"));?>,
  24.                 noResultsText: <?php echo json_encode(lang("reports_sales_generator_autocomplete_noResultsText"));?>,
  25.                 searchingText: <?php echo json_encode(lang("reports_sales_generator_autocomplete_searchingText"));?>,
  26.                 preventDuplicates: true,
  27.                 prePopulate: settings.prePopulate
  28.             });
  29.         });
  30.     }
  31. })(jQuery);
  32.  
  33. $("#matchType").live("change", function() {
  34.     if ($(this).val() == 'matchType_All')
  35.         $(".actions span.actionCondition").html(<?php echo json_encode(lang("reports_sales_generator_matchType_All_TEXT"));?>);
  36.     else
  37.         $(".actions span.actionCondition").html(<?php echo json_encode(lang("reports_sales_generator_matchType_Or_TEXT"));?>);
  38. });
  39.  
  40. $("a.AddCondition").live("click", function(e) {
  41.     var sInput = $("<input />").attr({"type": "text", "name": "value[]", "w":"", "value":""});
  42.     $('.conditions tr.duplicate:last').clone().insertAfter($('.conditions tr.duplicate:last'));
  43.     $("input", $('.conditions tr.duplicate:last')).parent().html("").append(sInput).children("input").tokenize();
  44.     $("option", $('.conditions tr.duplicate:last select')).removeAttr("disabled").removeAttr("selected").first().attr("selected", "selected");
  45.    
  46.     $('.conditions tr.duplicate:last').trigger('change');
  47.     e.preventDefault();
  48. })
  49.  
  50. $("a.DelCondition").live("click", function(e) {
  51.     if ($(this).parent().parent().parent().children().length > 1)
  52.         $(this).parent().parent().remove();
  53.    
  54.     e.preventDefault();
  55. })
  56.  
  57. $(".selectField").live("change", function() {
  58.     var sInput = $("<input />").attr({"type": "text", "name": "value[]", "w":"", "value":""});
  59.     var field = $(this);
  60.     // Remove Value Field
  61.     field.parent().parent().children("td.value").html("");
  62.     if ($(this).val() == 0)
  63.     {
  64.         field.parent().parent().children("td.condition").children(".selectCondition").attr("disabled", "disabled");
  65.         field.parent().parent().children("td.value").append(sInput.attr("disabled", "disabled"));      
  66.     }
  67.     else
  68.     {
  69.         field.parent().parent().children("td.condition").children(".selectCondition").removeAttr("disabled");  
  70.         if ($(this).val() == 2 || $(this).val() == 7 || $(this).val() == 10)
  71.         {
  72.             field.parent().parent().children("td.value").append(sInput);       
  73.         }
  74.         else
  75.         {
  76.             if ($(this).val() == 6)
  77.             {
  78.                 field.parent().parent().children("td.value").append($("<input />").attr({"type": "hidden", "name": "value[]", "value":""}));       
  79.             }
  80.             else
  81.             {
  82.                 field.parent().parent().children("td.value").append(sInput.attr("w", $("option:selected", field).attr('rel'))).children("input").tokenize();       
  83.             }
  84.         }
  85.         disableConditions(field, true);
  86.     }
  87. });
  88.  
  89. $(function() {
  90.     <?php
  91.         if (isset($prepopulate) and count($prepopulate) > 0) {
  92.             echo "var prepopulate = $.parseJSON('".json_encode($prepopulate)."');";
  93.         }
  94.     ?>
  95.     var sInput = $("<input />").attr({"type": "text", "name": "value[]", "w":"", "value":""});
  96.     $(".selectField").each(function(i) {
  97.         if ($(this).val() == 0) {
  98.             $(this).parent().parent().children("td.condition").children(".selectCondition").attr("disabled", "disabled");
  99.             $(this).parent().parent().children("td.value").html("").append(sInput.attr("disabled", "disabled"));   
  100.         } else {
  101.             if ($(this).val() != 2 && $(this).val() != 6 && $(this).val() != 7 && $(this).val() != 10) {
  102.                 $(this).parent().parent().children("td.value").children("input").attr("w", $("option:selected", $(this)).attr('rel')).tokenize({prePopulate: prepopulate.field[i][$(this).val()] });   
  103.             }
  104.             if ($(this).val() == 6) {
  105.                 $(this).parent().parent().children("td.value").html("").append($("<input />").attr({"type": "hidden", "name": "value[]", "value":""}));
  106.             }
  107.             disableConditions($(this), false);
  108.         }
  109.     });
  110.    
  111.     $("#start_month, #start_day, #start_year, #end_month, #end_day, #end_year").change(function()
  112.     {
  113.         $("#complex_radio").attr('checked', 'checked');
  114.     });
  115.  
  116.     $("#report_date_range_simple").change(function()
  117.     {
  118.         $("#simple_radio").attr('checked', 'checked');
  119.     });
  120. });
  121.  
  122. function disableConditions(elm, q) {
  123.     var allowed1 = ['1', '2'];
  124.     var allowed2 = ['7', '8', '9'];
  125.     var allowed3 = ['10', '11'];
  126.     var allowed4 = ['1', '2', '7', '8', '9'];
  127.     var allowed5 = ['1'];
  128.     var disabled = elm.parent().parent().children("td.condition").children(".selectCondition");
  129.    
  130.     if (q == true)
  131.         $("option", disabled).removeAttr("selected");
  132.    
  133.     $("option", disabled).attr("disabled", "disabled");
  134.     $("option", disabled).each(function() {
  135.         if (elm.val() == 11 && $.inArray($(this).attr("value"), allowed5) != -1) {
  136.             $(this).removeAttr("disabled");
  137.         }else if (elm.val() == 10 && $.inArray($(this).attr("value"), allowed4) != -1) {
  138.             $(this).removeAttr("disabled");
  139.         } else if (elm.val() == 6 && $.inArray($(this).attr("value"), allowed3) != -1) {
  140.             $(this).removeAttr("disabled");
  141.         } else if (elm.val() == 7 && $.inArray($(this).attr("value"), allowed2) != -1) {
  142.             $(this).removeAttr("disabled");
  143.         } else if (elm.val() != 6 && elm.val() != 7 && elm.val() != 10 && elm.val() != 11 && $.inArray($(this).attr("value"), allowed1) != -1) {
  144.             $(this).removeAttr("disabled");
  145.         }
  146.     });
  147.    
  148.     if (q == true)
  149.         $("option:not(:disabled)", disabled).first().attr("selected", "selected");
  150. }
  151.  
  152. </script>
  153. <div style="color:#000">
  154. <form name="salesReportGenerator" action="<?php echo site_url("reports/sales_generator"); ?>" method="post">
  155. <table id="contents">
  156.     <tr>
  157.         <td class="item_table">
  158.             <?php echo form_label(lang('reports_date_range'), 'report_date_range_label', array('class'=>'required','id'=>'label_new')); ?>
  159.             <div id='report_date_range_simple'>
  160.                 <input type="radio" name="report_type" id="simple_radio" value='simple'<?php if ($report_type != 'complex') { echo " checked='checked'"; }?>/>
  161.                 <?php echo form_dropdown('report_date_range_simple',$report_date_range_simple, $sreport_date_range_simple, 'id="report_date_range_simple"'); ?>
  162.             </div>
  163.             <div id='report_date_range_complex'>
  164.                 <input type="radio" name="report_type" id="complex_radio" value='complex'<?php if ($report_type == 'complex') { echo " checked='checked'"; }?>/>
  165.                 <?php echo form_dropdown('start_month',$months, $start_month, 'id="start_month"'); ?>
  166.                 <?php echo form_dropdown('start_day',$days, $start_day, 'id="start_day"'); ?>
  167.                 <?php echo form_dropdown('start_year',$years, $start_year, 'id="start_year"'); ?>
  168.                 -
  169.                 <?php echo form_dropdown('end_month',$months, $end_month, 'id="end_month"'); ?>
  170.                 <?php echo form_dropdown('end_day',$days, $end_day, 'id="end_day"'); ?>
  171.                 <?php echo form_dropdown('end_year',$years, $end_year, 'id="end_year"'); ?>
  172.             </div>
  173.         </td>
  174.     </tr>
  175.     <tr>
  176.         <td class="item_table">&nbsp;</td>
  177.     </tr>
  178.     <tr>
  179.         <td class="item_table">
  180.             <?php echo form_label(lang('reports_sales_generator_matchType'), 'matchType', array('class'=>'required','id'=>'label_new')); ?>
  181.             <select name="matchType" id="matchType">
  182.                 <option value="matchType_All"<?php if ($matchType != 'matchType_All') { echo " selected='selected'"; }?>><?php echo lang('reports_sales_generator_matchType_All')?></option>
  183.                 <option value="matchType_Or"<?php if ($matchType == 'matchType_Or') { echo " selected='selected'"; }?>><?php echo lang('reports_sales_generator_matchType_Or')?></option>
  184.             </select>
  185.             <br />
  186.             <em>
  187.                 <?php echo lang('reports_sales_generator_matchType_Help')?>
  188.             </em>
  189.         </td>
  190.     </tr>
  191.     <tr>
  192.         <td class="item_table">&nbsp;</td>
  193.     </tr>
  194.     <tr>
  195.         <td class="item_table">
  196.             <table class="conditions" style="border: none">
  197.                 <?php
  198.                     if (isset($field) and $field[0] > 0) {
  199.                         foreach ($field as $k => $v) {
  200.                 ?>
  201.                 <tr class="duplicate">
  202.                     <td class="field">
  203.                         <select name="field[]" class="selectField">
  204.                             <option value="0"><?php echo lang("reports_sales_generator_selectField_0") ?></option>                     
  205.                             <option value="1" rel="customers"<?php if($field[$k] == 1) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_1") ?></option>
  206.                             <option value="2" rel="itemsSN"<?php if($field[$k] == 2) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_2") ?></option>
  207.                             <option value="3" rel="employees"<?php if($field[$k] == 3) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_3") ?></option>
  208.                             <option value="4" rel="itemsCategory"<?php if($field[$k] == 4) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_4") ?></option>
  209.                             <option value="5" rel="suppliers"<?php if($field[$k] == 5) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_5") ?></option>
  210.                             <option value="6" rel="saleType"<?php if($field[$k] == 6) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_6") ?></option>
  211.                             <option value="7" rel="saleAmount"<?php if($field[$k] == 7) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_7") ?></option>
  212.                             <option value="8" rel="itemsKitName"<?php if($field[$k] == 8) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_8") ?></option>
  213.                             <option value="9" rel="itemsName"<?php if($field[$k] == 9) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_9") ?></option>
  214.                             <option value="10" rel="saleID"<?php if($field[$k] == 10) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_10") ?></option>
  215.                             <option value="11" rel="paymentType"<?php if($field[$k] == 11) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectField_11") ?></option>
  216.                         </select>
  217.                     </td>
  218.                     <td class="condition">
  219.                         <select name="condition[]" class="selectCondition">
  220.                             <option value="1"<?php if($condition[$k] == 1) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectCondition_1")?></option>
  221.                             <option value="2"<?php if($condition[$k] == 2) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectCondition_2")?></option>
  222.                             <option value="7"<?php if($condition[$k] == 7) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectCondition_7")?></option>
  223.                             <option value="8"<?php if($condition[$k] == 8) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectCondition_8")?></option>
  224.                             <option value="9"<?php if($condition[$k] == 9) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectCondition_9")?></option>
  225.                             <option value="10"<?php if($condition[$k] == 10) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectCondition_10")?></option>
  226.                             <option value="11"<?php if($condition[$k] == 11) echo " selected='selected'";?>><?php echo lang("reports_sales_generator_selectCondition_11")?></option>
  227.                         </select>
  228.                     </td>
  229.                     <td class="value">
  230.                         <input style="width: 400px !important;" type="text" name="value[]" w="" value="<?php echo $value[$k]; ?>"/>
  231.                     </td>
  232.                     <td class="actions">
  233.                         <span class="actionCondition">
  234.                         <?php
  235.                             if ($matchType == 'matchType_Or') {
  236.                                 echo lang("reports_sales_generator_matchType_Or_TEXT");
  237.                             } else {
  238.                                 echo lang("reports_sales_generator_matchType_All_TEXT");                   
  239.                             }
  240.                         ?>
  241.                         </span>
  242.                         <a class="AddCondition" href="#" title="<?php echo lang("reports_sales_generator_addCondition")?>"><?php echo lang("reports_sales_generator_addCondition")?></a>
  243.                         <a class="DelCondition" href="#" title="<?php echo lang("reports_sales_generator_delCondition")?>"><?php echo lang("reports_sales_generator_delCondition")?></a>
  244.                     </td>
  245.                 </tr>              
  246.                 <?php
  247.                         }
  248.                     } else {
  249.                 ?>
  250.                 <tr class="duplicate">
  251.                     <td class="field">
  252.                         <select name="field[]" class="selectField">
  253.                             <option value="0"><?php echo lang("reports_sales_generator_selectField_0") ?></option>                     
  254.                             <option value="1" rel="customers"><?php echo lang("reports_sales_generator_selectField_1") ?></option>
  255.                             <option value="2" rel="itemsSN"><?php echo lang("reports_sales_generator_selectField_2") ?></option>
  256.                             <option value="3" rel="employees"><?php echo lang("reports_sales_generator_selectField_3") ?></option>
  257.                             <option value="4" rel="itemsCategory"><?php echo lang("reports_sales_generator_selectField_4") ?></option>
  258.                             <option value="5" rel="suppliers"><?php echo lang("reports_sales_generator_selectField_5") ?></option>
  259.                             <option value="6" rel="saleType"><?php echo lang("reports_sales_generator_selectField_6") ?></option>
  260.                             <option value="7" rel="saleAmount"><?php echo lang("reports_sales_generator_selectField_7") ?></option>
  261.                             <option value="8" rel="itemsKitName"><?php echo lang("reports_sales_generator_selectField_8") ?></option>
  262.                             <option value="9" rel="itemsName"><?php echo lang("reports_sales_generator_selectField_9") ?></option>
  263.                             <option value="10" rel="saleID"><?php echo lang("reports_sales_generator_selectField_10") ?></option>
  264.                             <option value="11" rel="paymentType"><?php echo lang("reports_sales_generator_selectField_11") ?></option>
  265.                         </select>
  266.                     </td>
  267.                     <td class="condition">
  268.                         <select name="condition[]" class="selectCondition">
  269.                             <option value="1"><?php echo lang("reports_sales_generator_selectCondition_1")?></option>
  270.                             <option value="2"><?php echo lang("reports_sales_generator_selectCondition_2")?></option>
  271.                             <option value="7"><?php echo lang("reports_sales_generator_selectCondition_7")?></option>
  272.                             <option value="8"><?php echo lang("reports_sales_generator_selectCondition_8")?></option>
  273.                             <option value="9"><?php echo lang("reports_sales_generator_selectCondition_9")?></option>
  274.                             <option value="10"><?php echo lang("reports_sales_generator_selectCondition_10")?></option>
  275.                             <option value="11"><?php echo lang("reports_sales_generator_selectCondition_11")?></option>
  276.                         </select>
  277.                     </td>
  278.                     <td class="value">
  279.                         <input type="text" name="value[]" w="" value=""/>
  280.                     </td>
  281.                     <td class="actions">
  282.                         <span class="actionCondition">
  283.                         <?php
  284.                             if ($matchType == 'matchType_Or') {
  285.                                 echo lang("reports_sales_generator_matchType_Or_TEXT");
  286.                             } else {
  287.                                 echo lang("reports_sales_generator_matchType_All_TEXT");                   
  288.                             }
  289.                         ?>
  290.                         </span>
  291.                         <a class="AddCondition" href="#" title="<?php echo lang("reports_sales_generator_addCondition")?>"><?php echo lang("reports_sales_generator_addCondition")?></a>
  292.                         <a class="DelCondition" href="#" title="<?php echo lang("reports_sales_generator_delCondition")?>"><?php echo lang("reports_sales_generator_delCondition")?></a>
  293.                     </td>
  294.                 </tr>
  295.            
  296.                 <?php
  297.                     }
  298.                 ?>
  299.             </table>
  300.         </td>
  301.     </tr>  
  302.     <tr>
  303.         <td class="item_table" style="padding-top: 15px;">
  304.             <button id="button_one" name="generate_report" type="submit" value="1" id="generate_report" class="submit_button"><?php echo lang('common_submit')?></button>
  305.         </td>
  306.     </tr>      
  307. </table>
  308. </form>
  309.  
  310. <?php
  311.     if (isset($results)) echo $results;
  312. ?>
  313. </div></div></div>
  314. <?php $this->load->view("partial/footer"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement