zz - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of zz.php

  1. <!--begin::Breadcrumb-->
  2.  
  3. <ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-base my-1" style="padding-left: 38px;padding-bottom: 11px;">
  4.   <!--begin::Item-->
  5.   <li class="breadcrumb-item text-gray-500">
  6.     <a href="<?=base_url(); ?>master" class="text-gray-500 text-hover-primary"> Home </a>
  7.   </li>
  8.   <!--end::Item-->
  9.   <!--begin::Item-->
  10.   <li class="breadcrumb-item">
  11.     <span class="text-gray-500">/</span>
  12.   </li>
  13.   <!--end::Item-->
  14.   <!--begin::Item-->
  15.   <li class="breadcrumb-item text-gray-500"> Apps </li>
  16.   <!--end::Item-->
  17.   <!--begin::Item-->
  18.   <li class="breadcrumb-item">
  19.     <span class="text-gray-500">/</span>
  20.   </li>
  21.   <!--end::Item-->
  22.   <!--begin::Item-->
  23.   <li class="breadcrumb-item text-gray-500"> 
  24.       <a href="<?=base_url(); ?>master/employee" class="text-gray-500 text-hover-primary">Order</a>
  25.   </li>
  26.   <!--end::Item-->
  27.   <!--begin::Item-->
  28.   <li class="breadcrumb-item">
  29.     <span class="text-gray-500">/</span>
  30.   </li>
  31.   <!--end::Item-->
  32.   <!--begin::Item-->
  33.   <li class="breadcrumb-item text-gray-500"> add-ons Add</li>
  34.   <!--end::Item-->
  35. </ul>
  36. <!--end::Breadcrumb-->
  37.  
  38. <?php 
  39.                 $this->db->select('oh.id as order_id,oh.*,c.*');
  40.                 $this->db->from("order_header as oh");
  41.                 $this->db->join("customer as c","c.id=oh.customer_id");
  42.                 $this->db->where("oh.id",$id);
  43.                 $this->db->where("oh.status",1);
  44.                 $this->db->where("oh.status_id",2);
  45.                 $headedata=$this->db->get()->row();
  46.  
  47.  
  48.                 $this->db->select('od.*,ogd.*,odd.*');
  49.                 $this->db->from("order_detail_group_det as ogd");
  50.                 $this->db->join("order_detail_det as odd","ogd.order_detail_det_id=odd.id");
  51.                 $this->db->join("order_details as od","ogd.order_detail_id=od.id");          
  52.                 $this->db->where("od.status",1);
  53.                 $this->db->where("od.order_header_id",$headedata->id);
  54.                 $detailsdata=$this->db->get();
  55. ?>
  56.  
  57.  
  58. <!--begin::Content-->
  59. <div id="kt_app_content" class="app-content  flex-column-fluid " >
  60.     
  61.            
  62.         <!--begin::Content container-->
  63.         <div id="kt_app_content_container" class="app-container  container-fluid ">
  64.             <!--begin::Layout-->
  65. <div class="d-flex flex-column flex-lg-row">
  66.     <!--begin::Content-->
  67.     <div class="flex-lg-row-fluid mb-10 mb-lg-0 me-lg-7 me-xl-10">
  68.         <!--begin::Card--> 
  69. <div class="card">     
  70.     <!--begin::Card body-->
  71.     <div class="card-body p-12">
  72.         <!--begin::Form-->
  73.                 <form id="submitForm" name="addform" action="<?php echo base_url();?>welcome/addonsAction" method="post" enctype="multipart/form-data"  >
  74.             <!--begin::Wrapper-->
  75.             <div class="d-flex flex-column align-items-start flex-xxl-row">
  76.                                                         <div class="row">     
  77.                                                                
  78.                                                                 <!-- <div class="col-lg-6" style="width:100%;">
  79.                                                                         <a href="<?=base_url();?>Master" class="btn btn-primary"><i class="glyphicon glyphicon-home"></i></a>
  80.                                                                 </div> -->
  81.  
  82.                                                                 <div class="col-lg-6" style="width:100%;">
  83.                                                                         <span class="fs-2x fw-bold text-gray-800">Add-ons/specifications</span>
  84.                                                                 </div>               
  85.                                                                
  86.                                                                                                                        
  87.                                                         </div>
  88.                                                
  89.                         </div>
  90.                                                              
  91.             <!--end::Top-->       
  92.  
  93.             <!--begin::Separator-->
  94.             <div class="separator separator-dashed my-10"></div>
  95.             <!--end::Separator-->         
  96.  
  97.             <!--begin::Wrapper-->
  98.             <div class="mb-0">
  99.                         <div class="row gx-10 mb-5">
  100.                     <!--begin::Col-->
  101.                     <div class="col-lg-6">
  102.                                                 <label class="form-label fs-6 fw-bold text-gray-700 mb-3">
  103.                                                 <p class="addpara">Order Number</p>
  104.                                                 </label>
  105.  
  106.                         <!--begin::Input group-->
  107.                         <div class="mb-5" style="margin-top: -16px;">
  108.                                                 <input name="order_no" id="order_no" value="<?=$headedata->order_id ?>"required=""  type="text" class="form-control " readonly>
  109.                         <input name="header_id" id="header_id" value="<?=$headedata->order_id ?>"required=""  type="hidden" class="form-control " readonly>
  110.                        
  111.                                         </div>
  112.                         <!--end::Input group-->
  113.                                         </div>
  114.  
  115.                                         <div class="col-lg-6">
  116.                                                 <label class="form-label fs-6 fw-bold text-gray-700 mb-3">
  117.                                                 <p class="addpara">Group Number</p>
  118.                                                 </label>
  119.  
  120.                         <!--begin::Input group-->
  121.                         <div class="mb-5" style="margin-top: -16px;">
  122.                                                 <input name="order_no" id="order_no" value="<?=$headedata->order_id ?>"required=""  type="text" class="form-control " readonly>
  123.                         </div>
  124.                         <!--end::Input group-->
  125.                                         </div>
  126.  
  127.                                 </div>
  128.                 <!--begin::Row-->
  129.                 <div class="row gx-10 mb-5">
  130.                     <!--begin::Col-->
  131.                     <div class="col-lg-6">
  132.                                                 <label class="form-label fs-6 fw-bold text-gray-700 mb-3">
  133.                                                 <p class="addpara">Compay Name</p>
  134.                                                 </label>
  135.  
  136.                         <!--begin::Input group-->
  137.                         <div class="mb-5" style="margin-top: -16px;">
  138.                                                 <input name="companyname" id="companyname" value="<?=$headedata->company_name ?>" required=""  type="text" class="form-control " readonly >
  139.                         </div>
  140.                         <!--end::Input group-->
  141.                                         </div>
  142.  
  143.                                        
  144.  
  145.                                 </div>
  146.  
  147.                         </div>
  148.                           
  149.  
  150.                             
  151.  
  152.  
  153.  
  154.                                        
  155.   
  156.                  
  157.                
  158.                                    
  159.                        
  160.                         <?php
  161.                          $this->db->select('*');
  162.                                                                 $this->db->from('gender_master');                                                              
  163.                                                                 $this->db->where('status',1);                                                          
  164.                                                         $genderdetails=$this->db->get();       
  165.                                  $this->db->select('*');
  166.                                                                 $this->db->from('yarn_count');                                                         
  167.                                                                 $this->db->where('status',1);                                                          
  168.                                                                 $yarncount=$this->db->get();   
  169.                                  $this->db->select('*');
  170.                                                                 $this->db->from('product');                                                            
  171.                                                                 $this->db->where('status',1);                                                          
  172.                                                                 $styledetails=$this->db->get();
  173.                                  $this->db->select('*');
  174.                                                                 $this->db->from('sleeve_master');                                                              
  175.                                                                 $this->db->where('status',1);                                                          
  176.                                                                 $sleevdetails=$this->db->get();
  177.                                 $this->db->select('*');
  178.                                                                 $this->db->from('sizegroup_master');                                                           
  179.                                                                 $this->db->where('status',1);                                                          
  180.                                                                 $size=$this->db->get();
  181.                                 $this->db->select('*');
  182.                                                                 $this->db->from('brand');                                                              
  183.                                                                 $this->db->where('status',1);                                                          
  184.                                                                 $brand=$this->db->get();
  185.                                 $this->db->select('*');
  186.                                                                 $this->db->from('color_details');                                                              
  187.                                                                 $this->db->where('status',1);                                                          
  188.                                                                 $color_details=$this->db->get();       
  189.                                                                 $this->db->select('*');
  190.                                 $this->db->from('fabricant_master');                                                           
  191.                                                                 $this->db->where('status',1);                                                          
  192.                                                                 $fabricant_master=$this->db->get();                                                                                                                                                    
  193.                         ?>
  194. <div class="" style="overflow-x:scroll" >
  195. <table id="example1" class="table table-striped table-bordered " cellspacing="0" style="padding-top:0%;max-width:none !important;width:200% !important">
  196.     <thead>
  197.         <tr >
  198.            
  199.             <th width="10px"class="tdtexts">SNO</th>
  200.            <th width="100px" class="tdtexts">GROUP NO</th> 
  201.                         <th width="100px" class="tdtexts">COUNT</th>                        
  202.            <th width="100px" class="tdtexts">STYLE</th>
  203.                    <th width="100px" class="tdtexts">FABRICANT</th>
  204.             <th width="100px"class="tdtexts">SLEEVE</th>
  205.                         <th width="100px" class="tdtexts">RATIO</th> 
  206.                         <th width="100px" class="tdtexts">PHOTO</th> 
  207.                         <th width="100px" class="tdtexts">BRAND</th>
  208.            <th width="100px" class="tdtexts" >SIZE</th>
  209.                    <th width="100px" class="tdtexts" >BDL</th>
  210.                    <th width="100px" class="tdtexts" >PCS</th>
  211.                    <th width="100px" class="tdtexts" >TOTAL PCS</th>
  212.  
  213.                   
  214.                    <th width="100px" class="tdtexts" >GRMS</th>
  215.                    <th width="100px" class="tdtexts" >TOTAL KGS</th>
  216.                        
  217.                         <th width="100px" class="tdtexts">KD</th>
  218.                         <th width="100px" class="tdtexts">FD</th>
  219.  
  220.                         <th width="100px" class="tdtexts">KGS</th>
  221.                         <th width="100px" class="tdtexts">ROLL</th>
  222.                         <th width="100px" class="tdtexts">T/W</th>
  223.                         <th width="100px" class="tdtexts">SH</th>
  224.                        
  225.             
  226.         </tr>
  227.     </thead>
  228.         <?PHP $sno=1; ?>
  229.                    <tbody class="table-bordered" id="addrow">
  230.                         <?php foreach($detailsdata->result() as $row) { ?>
  231.                  <tr id="mainrow_<?=$sno?>" class="mainrow">
  232.                                 <td  class="tdtexts" style="padding-top:20px;width:100px;" id="tdrow_<?=$sno?>"><?=$sno?>
  233.                                 <input type="hidden" style="width:100%;" value="<?=$row->id ?>" required="true" name="items[<?=$sno?>][detailid]"  id="detailid_<?=$sno ?>" class="form-control inputleft detailid" /></td>
  234.                                 <input type="hidden" style="width:100%;" value="<?=$sno ?>" required="true" name="items[<?=$sno?>][sno]"  id="sno_<?=$sno ?>" class="form-control inputleft sno" /></td>
  235.                 <!--    <td class="tdtexts" >
  236.                                 <select id="gender_<?=$sno?>" name="items[<?=$sno?>][gender]"  class="form-control chosen-select gender"  readonly  />
  237.                                 <option value="">Select Gender</option>
  238.                                 <?php foreach($genderdetails->result() as $rows){ 
  239.                                         if($row->gender_id==$rows->id) {?>
  240.                                         <option value="<?=$rows->id ?>" selected ><?=$rows->name ?></option>
  241.                                         <?php } else { ?>
  242.                                                 <option value="<?=$rows->id ?>"  ><?=$rows->name ?></option>
  243.                                 <?php } } ?>
  244.                                 </select>
  245.                         </td>-->
  246.                         <td  class="tdtexts" style="padding-top:20px;width:100px;" id="tdrow_<?=$sno?>"><?=$row->group_no?> </td>
  247.                         <td class="tdtexts" >
  248.                                 <select id="count_<?=$sno?>" name="items[<?=$sno?>][count]"  class="form-control chosen-select count" readonly   />
  249.                                 <option value="">Select count</option>
  250.                                 <?php foreach($yarncount->result() as $rows){
  251.                                 if($row->yarn_count_id==$rows->id) {?>
  252.                                 <option value="<?=$rows->id ?>" selected ><?=$rows->yarn_count ?></option>
  253.                                 <?php } else { ?>
  254.                                                 <option value="<?=$rows->id ?>" ><?=$rows->yarn_count ?></option>
  255.                                 <?php } } ?>
  256.                                
  257.                                 </select>
  258.                         </td>
  259.                         <td class="tdtexts" >
  260.                                 <select id="style_<?=$sno?>" name="items[<?=$sno?>][style]"  class="form-control chosen-select style"  readonly  />
  261.                                 <option value="">Select style</option>
  262.                                 <?php foreach($styledetails->result() as $rows){ 
  263.                                         if($row->style_id==$rows->id) {?>?>
  264.                                 <option value="<?=$rows->id ?>" selected ><?=$rows->name ?></option>
  265.                                 <?php } else { ?>
  266.                                         <option value="<?=$rows->id ?>" ><?=$rows->name ?></option>
  267.                                 <?php } } ?>
  268.                                 </select>
  269.                         </td>
  270.                         <td class="tdtexts" >
  271.                                 <select id="fabricant_<?=$sno?>" name="items[<?=$sno?>][fabricant]"  class="form-control chosen-select fabricant"    />
  272.                                 <option value="0">Select Fabricant</option>
  273.                                 <?php foreach($fabricant_master->result() as $rows){ 
  274.                                         if($row->fabricant_id==$rows->id){
  275.                                 ?>
  276.                                 <option value="<?=$rows->id ?>" selected ><?=$rows->fabricant_name ?></option>
  277.                                
  278.                                 <?php } } ?>
  279.                                 </select>
  280.                         </td>
  281.                         <td class="tdtexts" >
  282.                                 <select id="sleeve_<?=$sno?>" name="items[<?=$sno?>][sleeve]"  class="form-control chosen-select sleeve"  readonly  />
  283.                                 <option value="">Select sleeve</option>
  284.                                 <?php foreach($sleevdetails->result() as $rows){ 
  285.                                         if($row->sleeve_id==$rows->id) {?>?>   ?>
  286.                                 <option value="<?=$rows->id ?>" selected ><?=$rows->name ?></option>
  287.                                 <?php } else { ?>
  288.                                         <option value="<?=$rows->id ?>" ><?=$rows->name ?></option>
  289.                                 <?php } } ?>
  290.                                 </select>
  291.                         </td>
  292.                         <td Style="display: flex" class="tdtexts"  >
  293.                        
  294.                                 <input id="ratio_<?=$sno ?>" name="items[<?=$sno ?>][ratio]"  type="text" class="form-control" value="<?=number_format($row->actual_ratio,0) ?>" required readonly   />
  295.                                 <label Style="text-align:center;padding-top:5px">:</label>
  296.                                 <input id="totalratio_<?=$sno ?>" name="items[<?=$sno ?>][totalratio]"  type="text" class="form-control" value=" <?=number_format($row->total_ratio,0) ?>" required readonly   />
  297.                                
  298.                         </td>
  299.                         <td class="tdtexts" >
  300.                        
  301.                                         <img id="frame_<?=$sno ?>" src="<?=base_url(); ?>uploads/orders/<?=$row->image ?>" width="100px" height="100px"/>
  302.                
  303.                 </td>
  304.                 <td class="tdtexts" >
  305.                                 <select id="brand_<?=$sno?>" name="items[<?=$sno?>][brand]"  class="form-control chosen-select brand"    />
  306.                                 <option value="0">Select Brand</option>
  307.                                 <?php foreach($brand->result() as $rows){ 
  308.                                         if($row->brand_id==$rows->id){
  309.                                 ?>
  310.                                 <option value="<?=$rows->id ?>" selected  ><?=$rows->name ?></option>
  311.                                
  312.                                 <?php } } ?>
  313.                                 </select>
  314.                         </td>
  315.                         <?php
  316.                         $this->db->select("*");
  317.                         $this->db->from("order_detail_det");
  318.                         $this->db->where("status",1);
  319.                         $this->db->where("id",$row->order_detail_det_id);
  320.                         $details=$this->db->get()->row();
  321.                          ?>
  322.                         <td align="center" > 
  323.                        
  324.                                 <table id="example2">
  325.                                        
  326.                                           <tbody  id="addsubrow111">
  327.                                          
  328.                                                 <?php $maxsizeid=0;
  329.                                                         $this->db->select("s.*");
  330.                                                         $this->db->from("sizegroup_mapping as sg");
  331.                                                         $this->db->join("size_details as s","sg.size_id=s.id");
  332.                                                         $this->db->where("sg.status",1);
  333.                                                         $this->db->where("s.status",1);
  334.                                                         $this->db->where("sg.group_id",$details->size_group_id);
  335.                                                         $sizegroup=$this->db->get();
  336.                                                         ?>
  337.  
  338.                                                         <tr id="subrow" class="subrow">
  339.                                                         <td class="tdtexts" >
  340.                                                         <?php foreach($sizegroup->result() as $row2) { 
  341.                                                         $maxsizeid=$row2->id;   ?>
  342.                                                                 <?=$row2->size_name ?>   
  343.                                                         <?php }        ?>
  344.                                                         </td>
  345.                                                         </tr>  
  346.                                        
  347.                                                          
  348.                                         </tbody>
  349.                                 </table>
  350.                         </td>
  351.                         </td>
  352.                         <td class="tdtexts"  >
  353.                                 <input id="bundle_<?=$sno ?>" name="items[<?=$sno ?>][bundle]" style="text-align:center" type="text" class="form-control bundle" value="<?=$row->bundle ?>" required readonly   />
  354.                         </td>
  355.                        
  356.                         <td class="tdtexts"  >
  357.                                 <input id="bundleqty_<?=$sno ?>" name="items[<?=$sno ?>][bundleqty]" style="text-align:center" type="text" class="form-control bundle" value="<?=$row->quantity/$row->bundle ?>" required readonly   />
  358.                         </td>
  359.                         <td class="tdtexts"  >
  360.                                 <input id="totalqty_<?=$sno ?>" name="items[<?=$sno ?>][totalqty]" style="text-align:center" type="text" class="form-control bundle" value="<?=$row->quantity ?>" required readonly   />
  361.                         </td>
  362.                         <?php 
  363.                         //fabricant calculation
  364.                         $totalsize=0;
  365.                         $totalweight=0;
  366.                         $actualweight=0;
  367.                          $this->db->select("aod.*");
  368.                          $this->db->from("order_add_ons_detail_det as aod");                
  369.                          $this->db->where("aod.status",1);
  370.                          $this->db->where("aod.detail_id",$row->order_detail_id);
  371.                          $fmdetails=$this->db->get();
  372.                         // print_r($this->db->last_query());
  373.                          foreach($fmdetails->result() as $aod)
  374.                          {
  375.                                 $this->db->select("sg.*");
  376.                                 $this->db->from("sizegroup_mapping as sg");                          
  377.                                 $this->db->where("sg.status",1);                               
  378.                                 $this->db->where("sg.group_id",$details->size_group_id);
  379.                                 $sizedetails=$this->db->get();
  380.                                 foreach($sizedetails->result() as $size)
  381.                                 {
  382.  
  383.                                         $this->db->select("fmd.*");
  384.                                         $this->db->from("fabricant_mapping_master as fmd");                  
  385.                                         $this->db->where("fmd.status",1);
  386.                                         $this->db->where("fmd.sleeve_id",$aod->sleeve_id);
  387.                                         $this->db->where("fmd.style_id",$row->style_id);
  388.                                         $this->db->where("fmd.size_id",$size->size_id);
  389.                                         $this->db->where("fmd.gender_id",$row->gender_id);
  390.                                         $this->db->where("fmd.count_id",$row->yarn_count_id);
  391.                                         $getfab_details=$this->db->get()->row();
  392.                                         //print_r($this->db->last_query());
  393.                                         if(!empty($getfab_details))
  394.                                         {
  395.  
  396.                                                 $totalweight +=$getfab_details->weight;
  397.                                         }
  398.                                         $totalsize++;
  399.  
  400.                                 }
  401.  
  402.                          }
  403.                          $actualweight=$totalweight;
  404.                          $totalweight=number_format($actualweight*$row->quantity,0);
  405.                         ?>
  406.                         <td class="tdtexts"  >
  407.                                 <input id="fabricantweight_<?=$sno ?>" name="items[<?=$sno ?>][fabricantweight]" style="text-align:center" type="text" class="form-control bundle" value="<?=number_format($actualweight,3) ?>" required readonly   />
  408.                         </td>
  409.                         <td class="tdtexts"  >
  410.                                 <input id="totalweight_<?=$sno ?>" name="items[<?=$sno ?>][totalweight]" style="text-align:center" type="text" class="form-control totalweight" value="<?=number_format($totalweight,0) ?>" required readonly   />
  411.                         </td>
  412.                         <?php 
  413.                                 $totalcolor=0;
  414.                                 $roundweight=0;
  415.                                 $indivualcolorweight=0;
  416.                                 $actualrollweight=0;
  417.                                 $actualroll=0;
  418.                                 $rondremaider=0;
  419.                                
  420.                                 $this->db->select("aoc.detail_id,count('aoc.id')as no_fo_color");
  421.                                 $this->db->from("order_color_detail_det as aoc");                    
  422.                                 $this->db->where("aoc.status",1);
  423.                                 $this->db->where("aoc.detail_id",$row->order_detail_id);
  424.                                 $this->db->group_by('aoc.detail_id');
  425.                                 $coloretails=$this->db->get()->row();
  426.                                 if(!empty($coloretails))
  427.                                 {
  428.                                         $totalcolor=$coloretails->no_fo_color;
  429.                                 }
  430.                                 $rondremaider=$totalweight%$totalcolor;
  431.                                 if($rondremaider !=0)
  432.                                 {
  433.                                         $roundweight=$totalweight+($totalcolor-$rondremaider);
  434.                                 }
  435.                                 else
  436.                                 {
  437.                                         $roundweight=$totalweight;
  438.                                 }
  439.                                 $indivualcolorweight=$roundweight/$totalcolor;
  440.                                                                
  441.                                                                
  442.                                 $this->db->select('*');
  443.                                 $this->db->from('fabricant_master');                                                           
  444.                                 $this->db->where('status',1);
  445.                                 $this->db->where('id',$row->fabricant_id);                                                             
  446.                                 $fabricant=$this->db->get()->row();
  447.                                 if(!empty($fabricant))
  448.                                 {
  449.                                         if($fabricant->fixed_roll_weight==0)
  450.                                         {
  451.                                                 if($indivualcolorweight>=40)
  452.                                                 {
  453.                                                         $remaider=array();
  454.                                                         $minremainder=0;
  455.                                                         for($i=20;29>=$i;$i++)
  456.                                                         {
  457.                                                                 $re=$indivualcolorweight%$i;
  458.                                                                 array_push($remaider,$re);
  459.                                                                
  460.  
  461.                                                         }
  462.                                                         $minremainder=min($remaider);
  463.                                                         if($minremainder !=0)
  464.                                                         {
  465.                                                                 for($i=20;29>=$i;$i++)
  466.                                                                 {
  467.                                                                         $re=$indivualcolorweight%$i;
  468.                                                                         if($re==$minremainder)
  469.                                                                         {
  470.                                                                                 $actualrollweight=$i;
  471.                                                                         }
  472.                                                                        
  473.                                                                        
  474.        
  475.                                                                 }
  476.                                                                 //  echo $roundweight;
  477.                                                                 //  echo '</br>';
  478.                                                                 //  echo $rondremaider;
  479.                                                                 //  echo '</br>';
  480.                                                                 //  echo $indivualcolorweight;
  481.                                                                 //  echo '</br>';
  482.                                                                 // echo $minremainder;
  483.  
  484.                                                                 $roll=($indivualcolorweight -$minremainder)/$actualrollweight;
  485.  
  486.                                                                 $actualroll=$roll;
  487.                                                                 //if($actualrollweight<30)
  488.                                                                 //{
  489.                                                                 $actualrollweight=$actualrollweight+1;
  490.                                                                 //}
  491.                                                         }
  492.                                                         else
  493.                                                         {
  494.                                                                 for($i=20;30>=$i;$i++)
  495.                                                                 {
  496.                                                                         $re=$indivualcolorweight%$i;
  497.                                                                         if($re==$minremainder)
  498.                                                                         {
  499.                                                                                 $actualrollweight=$i;
  500.                                                                         }
  501.                                                                        
  502.                                                                        
  503.        
  504.                                                                 }
  505.                                                                
  506.                                                                 $roll=($indivualcolorweight )/$actualrollweight;
  507.                                                                 $actualroll=$roll;
  508.                                                         }
  509.  
  510.                                                 }
  511.                                                 else if($indivualcolorweight<=39 && $indivualcolorweight>=31  )
  512.                                                 {
  513.                                                         $remaider=array();
  514.                                                         $minremainder=0;
  515.                                                         for($i=15;19>=$i;$i++)
  516.                                                         {
  517.                                                                 $re=$indivualcolorweight%$i;
  518.                                                                 array_push($remaider,$re);
  519.                                                                
  520.  
  521.                                                         }
  522.                                                         $minremainder=min($remaider);
  523.                                                         //echo $minremainder;
  524.                                                         if($minremainder !=0)
  525.                                                         {
  526.                                                                 for($i=15;19>=$i;$i++)
  527.                                                                 {
  528.                                                                         $re=$indivualcolorweight%$i;
  529.                                                                         if($re==$minremainder)
  530.                                                                         {
  531.                                                                                 $actualrollweight=$i+1;
  532.                                                                         }
  533.                                                                        
  534.                                                                        
  535.        
  536.                                                                 }
  537.                                                                 $actualroll=2;
  538.                                                         }
  539.                                                         else
  540.                                                         {
  541.                                                                 for($i=15;19>=$i;$i++)
  542.                                                                 {
  543.                                                                         $re=$indivualcolorweight%$i;
  544.                                                                         if($re==$minremainder)
  545.                                                                         {
  546.                                                                                 $actualrollweight=$i;
  547.                                                                         }
  548.                                                                        
  549.                                                                        
  550.        
  551.                                                                 }
  552.                                                                 $actualroll=2;
  553.                                                         }
  554.                                                        
  555.                                                 }
  556.                                                 else if($indivualcolorweight<=30 && $indivualcolorweight>=20)
  557.                                                 {
  558.                                                         $actualrollweight=$indivualcolorweight;
  559.                                                         $actualroll=1;
  560.                                                 }
  561.                                                 else if($indivualcolorweight<=19 && $indivualcolorweight>=10)
  562.                                                 {
  563.                                                         $actualrollweight=$indivualcolorweight;
  564.                                                         $actualroll=1;
  565.                                                 }
  566.                                                 else
  567.                                                 {
  568.                                                         $actualrollweight=10;
  569.                                                         $actualroll=1; 
  570.                                                 }                                      
  571.  
  572.                                                
  573.                                         }
  574.                                         else
  575.                                         {
  576.                                                 if($indivualcolorweight>$fabricant->fixed_roll_weight)
  577.                                                 {
  578.                                                         $re=$indivualcolorweight%$fabricant->fixed_roll_weight;
  579.                                                         if($re!=0)
  580.                                                         {
  581.                                                         $actualrollweight=$fabricant->fixed_roll_weight;
  582.                                                         $addre=$fabricant->fixed_roll_weight-$re;
  583.                                                         $actualroll=($indivualcolorweight+$addre)/$fabricant->fixed_roll_weight;
  584.                                                          
  585.                                                         }
  586.                                                         else
  587.                                                         {
  588.                                                                 $actualrollweight=$fabricant->fixed_roll_weight;
  589.                                                                 $actualroll=$indivualcolorweight/$fabricant->fixed_roll_weight;
  590.                                                        
  591.                                                         }
  592.                                                 }
  593.                                                 else
  594.                                                 {
  595.                                                                 $actualrollweight=$fabricant->fixed_roll_weight;
  596.                                                                 $actualroll=1;
  597.  
  598.                                                 }
  599.  
  600.                                                        
  601.                                         }
  602.  
  603.  
  604.                                 }      
  605.                         ?>
  606.                         <td class="tdtexts" >
  607.                                 <input id="kd_<?=$sno ?>" name="items[<?=$sno ?>][kd]" style="text-align:center" type="text" class="form-control kd" value="" required    />
  608.                         </td>
  609.                         <td class="tdtexts" >
  610.                                 <input id="fd_<?=$sno ?>" name="items[<?=$sno ?>][fd]" style="text-align:center" type="text" class="form-control fd" value="" required    />
  611.                         </td>
  612.                         <td class="tdtexts" >
  613.                                 <input id="kgs_<?=$sno ?>" name="items[<?=$sno ?>][kgs]" style="text-align:center" type="text" class="form-control kgs" value="<?=$actualrollweight ?>" required    />
  614.                         </td>
  615.                         <td class="tdtexts" >
  616.                                 <input id="roll_<?=$sno ?>" name="items[<?=$sno ?>][roll]" style="text-align:center" type="text" class="form-control roll" value="<?=$actualroll*$totalcolor ?>" required    />
  617.                         </td>
  618.                         <td class="tdtexts" >
  619.                                 <input id="totalrollwight_<?=$sno ?>" name="items[<?=$sno ?>][totalrollweight]" style="text-align:center" type="text" class="form-control totalroll" value="<?=($actualroll*$totalcolor)*$actualrollweight ?>" required    />
  620.                         </td>
  621.                         <td class="tdtexts" >
  622.                                 <input id="sh_<?=$sno ?>" name="items[<?=$sno ?>][sh]" style="text-align:center" type="text" class="form-control sh" value="<?=(($actualroll*$totalcolor)*$actualrollweight)-$totalweight?> " required    />
  623.                         </td>
  624.                                
  625.                                
  626.                                
  627.                
  628.        
  629.                 </tr>  
  630.                 <?php $sno++; } ?>          
  631.         </tbody>
  632.     </table>
  633.         </div>
  634.                         <div class="col-sm-12" style="text-align:right" >
  635.                         <input type="button" value="Return" class="btn btn-info" id="btnReturn" style="border: none;padding: 10px;">
  636.        
  637.                                 <input type="button" value="Submit" class="btn btn-primary" id="submit" style="border: none;padding: 10px;">
  638.                
  639.                         </div>
  640.  
  641.                 </form>
  642.         </div>
  643. </div>
  644.  
  645.  
  646. <script>
  647.         $(document).on('click','#btnReturn',function (e){
  648.         window.location.href = "<?=base_url()?>Welcome/specification_view";
  649. });
  650.         $(document).on('click','.addProduct',function(){
  651.                 //alert("bv");
  652.         id_attr=$(this).attr('id');
  653.         elementid=id_attr.split('_');   
  654.         id=parseInt(elementid[1]);
  655.         AddProductRow(id);
  656. });    
  657. function AddProductRow(id)
  658. {
  659.         //alert("bv");
  660.                 var id_attr=elementid='';
  661.                 var max=value=0;    
  662.                         $('.mainrow').each(function(){
  663.                         id_attr=$(this).attr('id');
  664.                         elementid=id_attr.split('_');   
  665.                         id=parseInt(elementid[1]);
  666.                         if(id>max)
  667.                                 max=id;
  668.                 });
  669.                 rowCount=max+1;
  670.                 //alert(rowCount);
  671.                 var rowCount2=1;
  672.                
  673.                         // var markup=' <tr id="mainrow_'+rowCount+'" class="mainrow">';
  674.                         //     markup+='<td  class="tdtexts" style="padding-top:20px;width:100px;" id="tdrow_'+rowCount+'">'+rowCount+'';
  675.                         //     markup+='<input type="hidden" style="width:100%;" value="'+rowCount+'" required="true" name="items['+rowCount+'][sno]"  id="sno_'+rowCount+'" class="form-control inputleft sno" /></td>';
  676.                         //     markup+='<td class="tdtexts" >';
  677.                         //     markup+='<select id="gender_'+rowCount+'" name="items['+rowCount+'][gender]"  class="form-control chosen-select gender"    />';
  678.                         //     markup+='<option value="">Select Gender</option>';
  679.                         //     markup+='<?php foreach($genderdetails->result() as $rows){ ?>';
  680.                         //     markup+='<option value="<?=$rows->id ?>" ><?=$rows->name ?></option>';
  681.                         //     markup+='<?php } ?>';
  682.                         //     markup+='</select>';
  683.                         //     markup+='</td>';
  684.                         //     markup+='<td class="tdtexts" >';
  685.                         //     markup+='<select id="count_'+rowCount+'" name="items['+rowCount+'][count]"  class="form-control chosen-select count"    />';
  686.                         //     markup+='<option value="">Select count</option>';
  687.                         //     markup+='<?php foreach($yarncount->result() as $rows){ ?>';
  688.                         //     markup+='<option value="<?=$rows->id ?>" ><?php echo str_replace("'","",$rows->yarn_count) ?></option>';
  689.                         //     markup+='<?php } ?>';
  690.                         //     markup+='</select>';
  691.                         //     markup+='</td>';
  692.                         //     markup+='<td class="tdtexts" >';
  693.                         //     markup+='<select id="style_'+rowCount+'" name="items['+rowCount+'][style]"  class="form-control chosen-select style"    />';
  694.                         //     markup+='<option value="">Select style</option>';
  695.                         //     markup+='<?php foreach($styledetails->result() as $rows){ ?>';
  696.                         //     markup+='<option value="<?=$rows->id ?>" ><?=$rows->name ?></option><?php } ?></select>   </td>';
  697.                         //     markup+='<td class="tdtexts" >';
  698.                         //     markup+='<select id="sleeve_'+rowCount+'" name="items['+rowCount+'][sleeve]"  class="form-control chosen-select sleeve"    />';
  699.                         //     markup+='<option value="">Select sleeve</option>';
  700.                         //     markup+='<?php foreach($sleevdetails->result() as $rows){ ?>';
  701.                         //     markup+='<option value="<?=$rows->id ?>" ><?php echo str_replace("'","",$rows->name) ?></option>';
  702.                         //     markup+='<?php } ?>';
  703.                         //     markup+='</select>';
  704.                         //     markup+='</td>';
  705.                         //     markup+='<td align="center" > ';
  706.                        
  707.                         //     markup+='<table id="example2_'+rowCount+'">';                         
  708.                         //     markup+='<tbody  id="addsubrow">';
  709.                         //     markup+='<tr id="subrow_'+rowCount+'_'+rowCount2+'" class="subrow_'+rowCount+'">';
  710.                         //     markup+='<td class="tdtexts" >';
  711.                         //     markup+='<select  name="items2['+rowCount+']['+rowCount2+'][size]"   id="size_'+rowCount+'_'+rowCount2+'"  class="form-control inputright sizegroup calculateAllValue customvalidblur custom-select ">';
  712.                         //     markup+='<option value="0">select size</option>';
  713.                         //     markup+='       </select></td>';       
  714.                         //     markup+='<td class="tdtexts" >        ';                     
  715.                         //     markup+='<a class="addSubProduct btn-sm btn-success btn-inline " id="insert_'+rowCount+'_'+rowCount2+'"style="margin-top:0px;"  ><i class="glyphicon glyphicon-plus"></i></a>';
  716.                         //     markup+='<a class="removeSubProduct btn-sm btn-danger btn-inline" id="delete_'+rowCount+'_'+rowCount2+'" style="margin-top:0px;" ><i class="glyphicon glyphicon-remove"></i></a>';
  717.                         //     markup+='</td></tr>     </tbody></table></td></td>';
  718.                         //     markup+='<td Style="display: flex" class="tdtexts"  >';                   
  719.                         //     markup+='<input id="ratio_'+rowCount+'" name="items['+rowCount+'][ratio]"  type="text" class="form-control" value="" required    />';
  720.                         //     markup+='<label Style="text-align:center;padding-top:5px">:</label>';
  721.                         //     markup+='<input id="totalratio_'+rowCount+'" name="items['+rowCount+'][totalratio]"  type="text" class="form-control totalratio" value=" " required value=""   /></td>';
  722.                         //     markup+='<td class="tdtexts" >';
  723.                         //     markup+='<input id="bundal_'+rowCount+'" name="items['+rowCount+'][bundle]" style="text-align:center" type="text" class="form-control bundal" value="" required value=""   />';
  724.                         //     markup+='</td>';
  725.                         //     markup+='<td class="tdtexts" >';
  726.                         //     markup+='<a class="addProduct btn-sm btn-success btn-inline " id="insert_'+rowCount+'"style="margin-top:0px;"  ><i class="glyphicon glyphicon-plus"></i></a>';
  727.                         //     markup+='<a class="removeProduct btn-sm btn-danger btn-inline " id="delete_'+rowCount+'" style="margin-top:9px;"  ><i class="glyphicon glyphicon-remove"></i></a>';
  728.                         //     markup+='</td>';
  729.                         //     markup+='</tr>';               
  730.                         //     $("#addrow").append(markup);
  731.                         //     loadsizegroup(rowCount,rowCount2);
  732.                         //$('#style_'+rowCount).focus();
  733.        
  734. }
  735.  
  736. $(document).on("click",".removeProduct",function(){
  737.         id_arr = $(this).attr('id');
  738.         element_id = id_arr.split("_");
  739.         id = element_id[1];
  740.        
  741.                 $(this).parent().parent().remove(); 
  742.        
  743.        
  744.        
  745. });
  746. $(document).on('click','.addSubProduct',function(){
  747.         id_attr=$(this).attr('id');
  748.         elementid=id_attr.split('_');   
  749.         id=parseInt(elementid[1]);
  750.         addSubProduct(id);
  751. });
  752. function addSubProduct(id)
  753. {
  754.         var id_attr=elementid='';
  755.                         var max=value=0;    
  756.                                 $('.subrow_'+id).each(function(){
  757.                                 id_attr=$(this).attr('id');
  758.                                 elementid=id_attr.split('_');   
  759.                                 id2=parseInt(elementid[2]);
  760.                                 if(id2>max)
  761.                                         max=id2;
  762.                         });
  763.                         rowCount=max+1;
  764.                                 markup='<tr id="subrow_'+id+'_'+rowCount+'" class="subrow_'+id+' tdtexts" >';                      
  765.                                
  766.                                 markup+='<td >    ';
  767.                                 markup+='<select  name="items2['+id+']['+rowCount+'][addons]"   id="addons_'+id+'_'+rowCount+'"  class="form-control inputright addons calculateAllValue customvalidblur custom-select ">';
  768.                                 markup+='<option value="0">select</option>';
  769.                                 markup+='<?php foreach($sleevdetails->result() as $row){ ?><option value="<?=$row->id ?>"><?= str_replace("'","",$row->name) ?></option>';
  770.                                 markup+='<?php } ?>';
  771.                                 markup+='</select>';
  772.                                 markup+='</td>';
  773.                                
  774.                                 markup+='<td >';
  775.                                 markup+='<a class="addSubProduct btn-sm btn-success btn-inline " id="insert_'+id+'_'+rowCount+'"style="margin-top:0px;"  ><i class="glyphicon glyphicon-plus"></i></a>';
  776.                                 markup+='<a class="removeSubProduct btn-sm btn-danger btn-inline" id="delete_'+id+'_'+rowCount+'" style="margin-top:0px;" ><i class="glyphicon glyphicon-remove"></i></a>';
  777.                        
  778.                                 markup+='</td>';
  779.                                 markup+='</tr>';
  780.  
  781.                                                                                
  782.                                 $(markup).insertAfter('#subrow_'+id+'_'+max);
  783.                                 //loadsizegroup(id,rowCount);
  784. }
  785.  
  786. $(document).on("click",".removeSubProduct",function(){
  787.         id_arr = $(this).attr('id');
  788.         element_id = id_arr.split("_");
  789.         id = element_id[1];
  790.        
  791.                 $(this).parent().parent().remove(); 
  792.                
  793.        
  794.        
  795. });
  796. $(document).on('click','.addSubProduct1',function(){
  797.         id_attr=$(this).attr('id');
  798.         elementid=id_attr.split('_');   
  799.         id=parseInt(elementid[1]);
  800.         addSubProduct1(id);
  801. });
  802. function addSubProduct1(id)
  803. {
  804.         var id_attr=elementid='';
  805.                         var max=value=0;    
  806.                                 $('.csubrow_'+id).each(function(){
  807.                                 id_attr=$(this).attr('id');
  808.                                 elementid=id_attr.split('_');   
  809.                                 id2=parseInt(elementid[2]);
  810.                                 if(id2>max)
  811.                                         max=id2;
  812.                         });
  813.                         rowCount=max+1;
  814.                                 markup='<tr id="csubrow_'+id+'_'+rowCount+'" class="csubrow_'+id+' tdtexts" >';                    
  815.                                
  816.                                 markup+='<td >    ';
  817.                                 markup+='<select  name="items3['+id+']['+rowCount+'][color]"   id="color_'+id+'_'+rowCount+'"  class="form-control inputright color calculateAllValue customvalidblur custom-select ">';
  818.                                 markup+='<option value="0">select</option>';
  819.                                 markup+='<?php foreach($color_details->result() as $row){ ?><option value="<?=$row->id ?>"><?= str_replace("'","",$row->color_name) ?></option>';
  820.                                 markup+='<?php } ?>';
  821.                                 markup+='</select>';
  822.                                 markup+='</td>';
  823.                                
  824.                                 markup+='<td >';
  825.                                 markup+='<a class="addSubProduct1 btn-sm btn-success btn-inline " id="insert_'+id+'_'+rowCount+'"style="margin-top:0px;"  ><i class="glyphicon glyphicon-plus"></i></a>';
  826.                                 markup+='<a class="removeSubProduct btn-sm btn-danger btn-inline" id="delete_'+id+'_'+rowCount+'" style="margin-top:0px;" ><i class="glyphicon glyphicon-remove"></i></a>';
  827.                        
  828.                                 markup+='</td>';
  829.                                 markup+='</tr>';
  830.  
  831.                                                                                
  832.                                 $(markup).insertAfter('#csubrow_'+id+'_'+max);
  833.                                 //loadsizegroup(id,rowCount);
  834. }
  835.  
  836.  
  837.         $(document).on('click','#submit',function (e){
  838.        
  839.        
  840.                
  841.                 if(flag=commonArrayValidation())
  842.                 {
  843.                         //alert(flag);
  844.                
  845.                         $('#submit').prop('disabled',true);
  846.                         var form = $('form')[0]; // You need to use standart javascript object here
  847.                         var formData = new FormData(form); 
  848.                         var url=form.action;
  849.                         $.ajax({
  850.                                                 url:url,
  851.                                                 type:'POST',
  852.                                                 data:formData,
  853.                                                 contentType:false,
  854.                                                 cache:false,
  855.                                                 processData:false,
  856.                                                 dataType:'json',
  857.                                                 success:function(result)
  858.                                                 {
  859.                                                                
  860.                                                         //alert("Order Successfull Saved....");
  861.                                                         console.log(result);
  862.                                                         //showMessage(result.message);
  863.                                                         if(result.status==200)
  864.                                                         {
  865.                                                                 alert(result.message,result.status);
  866.                                                                 $('#sequenceNumber').val(result.sequenceNumber);
  867.                                                                 $('#submit').prop('disabled',true);
  868.                                                         }
  869.                                                         else
  870.                                                         {
  871.                                                                 alert(result.message,result.status);
  872.                                                                 $('#submit').prop('disabled',false);
  873.                                                         }
  874.                                                 },
  875.                                                 error:function(result){
  876.                                                         alert('Server Error');
  877.                                                         $('#submit').prop('disabled',false);
  878.                                                 }
  879.                                         });
  880.                        
  881.                 }
  882.        
  883.  
  884. });
  885.  
  886. function commonArrayValidation()
  887. {
  888.          flag=true;
  889.        
  890.         $('.mainrow').each(function(){
  891.                                
  892.                                 var id_arr = $(this).attr('id');
  893.                                 var element_id = id_arr.split("_");
  894.                                 var id = element_id[1];
  895.                                
  896.                                 brad=$('#brand_'+id).val();                            
  897.                                
  898.                                
  899.                                 if(brad==0)
  900.                                 {
  901.                                        
  902.                                         $('#brand_'+id).css('border','2px solid red');
  903.                                         flag=false;                    
  904.                                         //return false;
  905.                                        
  906.                                 }
  907.                                
  908.                                 $('.subrow_'+id).each(function()
  909.                                 {
  910.                                         var id_arr = $(this).attr('id');
  911.                                         var element_id = id_arr.split("_");
  912.                                         var id1 = element_id[2];
  913.                                         addons=parseFloat($('#addons_'+id+'_'+id1).val());
  914.                                        
  915.                                        
  916.                                
  917.                                                         if(addons==0)
  918.                                                         {
  919.                                                                 $('#addons_'+id+'_'+id1).css('border','2px solid red');
  920.                                                                 flag=false;
  921.                                                                 return flag;
  922.                                                                
  923.                                                         }
  924.                                                        
  925.                                        
  926.                                 });
  927.                                 $('.csubrow_'+id).each(function()
  928.                                 {
  929.                                         var id_arr = $(this).attr('id');
  930.                                         var element_id = id_arr.split("_");
  931.                                         var id1 = element_id[2];
  932.                                         color=parseFloat($('#color_'+id+'_'+id1).val());
  933.                                        
  934.                                        
  935.                                
  936.                                                         if(color==0)
  937.                                                         {
  938.                                                                 $('#color_'+id+'_'+id1).css('border','2px solid red');
  939.                                                                 flag=false;
  940.                                                                 return flag;
  941.                                                                
  942.                                                         }
  943.                                                        
  944.                                        
  945.                                 });
  946.                                
  947.                 });
  948.        
  949.                
  950.         return flag;
  951. }
  952.  
  953.  
  954. </script>
  955.  
  956.        
File Description
  • zz
  • PHP Code
  • 15 Mar-2024
  • 31.8 Kb
You can Share it: