EVOLUTION-NINJA
Edit File: Planning_yarn.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Planning_yarn extends CI_Model { public function __construct() { parent::__construct(); } //insert planning yarn here public function planning_yarn_insert($quality_data) { $qualityinsert = $this->db->insert('planning_yarn', $quality_data); if ($qualityinsert) { return true; } else { return false; } } //checking where specification is exists or not public function check_spec_exists() { $query = $this->db->get('planning_yarn'); if ($query->num_rows() > 0) { return $query->result(); } else { return false; } } //display yarn quality data here public function display_yarnqty_data() { $query = $this->db->get('planning_yarn'); return $query->result(); } public function get_outsource_planning_orders($where) { $this->db->select('o.*,sos.planned_by,sos.planningStatus'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where($where); $this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } //display plannedorder public function display_order() { $query = $this->db->get('orders'); return $query->result(); } public function get_unplanned_orders() { $this->db->select('o.*'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'unplanned'); $this->db->where('so.article_type', 'inhouse'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function get_in_house_pending_shadeNum($orderID, $status) { $this->db->select('sos.*'); //$this->db->from('sub_orders so'); $this->db->from('sub_order_shades sos'); $this->db->join('sub_orders so', 'sos.subOrderID = so.id'); $this->db->where('so.article_type', 'inhouse'); $this->db->where('so.orderID', $orderID); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planned_by !=',''); $this->db->where($status); //$this->db->where('sos.planningStatus', 'planned'); $query = $this->db->get(); return $query->result(); } public function get_outsource_unplanned_orders() { $this->db->select('o.*,sos.planned_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'unplanned'); $this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function get_outsource_planned_orders() { $this->db->select('o.*,sos.planned_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'planned'); $this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function get_in_house_shadeNoo($orderID, $status) { $this->db->select('sos.*'); $this->db->from('sub_orders so'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->where('so.article_type', 'inhouse'); $this->db->where('so.orderID', $orderID); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', $status); $this->db->where('sos.planned_by !=',''); $query = $this->db->get(); return $query->result(); } public function get_planned_orders() { $this->db->select('o.*,sos.planned_by,so.created_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'planned'); $this->db->where('so.article_type', 'inhouse'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } //display warp denier based on yarn name in article master public function getwarpdenier($yarnname) { $query = $this->db->query('SELECT DISTINCT(yarnDenier) FROM import_yarn where yarnName="' . $yarnname . '" AND yarnType="Warp"'); return $query->result(); } //display weft denier based on yarn name in article master public function getweftdenier($yarnname) { $query = $this->db->query('SELECT DISTINCT(yarnDenier) FROM import_yarn where yarnName="' . $yarnname . '" AND yarnType="Weft"'); return $query->result(); } public function display_shadeType_Name($shadeType,$articleNo,$s_no) { $query = $this->db->query('SELECT articleID FROM article_master where articleNo="' . $articleNo . '"'); $r=$query->row(); $articleID=$r->articleID; //echo'<pre>';print_r($query->row());exit; $query = $this->db->query('SELECT * FROM shade_master where shadeID="' . $s_no . '" and shadeType="' . $shadeType . '" and articleID="' . $articleID . '"'); return $query->result(); } //display warp specification based on yarn name in article master public function getwarpspecification($yarndenier,$yarnname) { $query = $this->db->query('SELECT DISTINCT(yarnSpecification) FROM import_yarn where yarnDenier="' . $yarndenier . '" AND yarnType="Warp" AND yarnName="'.$yarnname.'"'); return $query->result(); } public function gethanklength($quality,$denier,$specification) { $query = $this->db->query('SELECT DISTINCT(hankLength) FROM import_yarn where yarnDenier="' . $denier . '" AND yarnType="Warp" AND yarnName="'.$quality.'"AND yarnSpecification="'.$specification.'"'); return $query->row(); } public function getwefthanklength($quality,$denier,$specification) { $query = $this->db->query('SELECT DISTINCT(hankLength) FROM import_yarn where yarnDenier="' . $denier . '" AND yarnType="Weft" AND yarnName="'.$quality.'"AND yarnSpecification="'.$specification.'"'); return $query->row(); } //display weft specification based on yarn name in article master public function getweftspecification($yarndenier,$yarnname) { $query = $this->db->query('SELECT DISTINCT(yarnSpecification) FROM import_yarn where yarnDenier="' . $yarndenier . '" AND yarnType="Weft" AND yarnName="'.$yarnname.'"'); return $query->result(); } public function get_shadeNo($orderID, $status) { $this->db->select('sos.*'); $this->db->from('sub_orders so'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); //$this->db->where('so.article_type', 'outsource'); $this->db->where('so.orderID', $orderID); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', $status); $this->db->where('sos.add_suborder',0); $query = $this->db->get(); return $query->result(); } public function get_in_house_shadeNo($orderID, $status) { $this->db->select('sos.*'); $this->db->from('sub_orders so'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->where('so.article_type', 'inhouse'); $this->db->where('so.orderID', $orderID); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', $status); $query = $this->db->get(); return $query->result(); } public function get_outsource_shadeNo($orderID, $status) { $this->db->select('sos.*'); $this->db->from('sub_orders so'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->where('so.article_type', 'outsource'); $this->db->where('so.orderID', $orderID); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', $status); $query = $this->db->get(); return $query->result(); //echo $this->db->last_query();exit; // $confirmation = "Yes"; // $this->db->from('sub_orders'); // $this->db->where('orderID', $orderID); // $this->db->where('orderConfirm', $confirmation); // $this->db->join('sub_order_shades', 'sub_order_shades.subOrderID = sub_orders.id'); // $query = $this->db->get(); // // // //$query = $this->db->get_where('orders', array('id' => $orderID)); // return $query->result(); } public function get_planning_details($orderID) { $this->db->from('orders'); $this->db->where('id', $orderID); $query = $this->db->get(); $result=$query->result(); foreach($result as $val) { $oslNo=$val->oslNo; } //print_r($result); die(); //$query = $this->db->query('SELECT DISTINCT(yarnSpecification) FROM import_yarn where yarnDenier="' . $yarndenier . '"'); $this->db->from('planned_order'); $this->db->where('oslNo', $result[0]->oslNo); $query = $this->db->get(); //$result=$query->result(); return $query->row(); } public function get_po_details($orderID) { $this->db->from('orders'); $this->db->where('id', $orderID); $query = $this->db->get(); $result=$query->result(); foreach($result as $val) { $oslNo=$val->oslNo; } $query = $this->db->query("SELECT * FROM `po_plan` WHERE planningOrderID IN ( SELECT id FROM planned_order WHERE subNo IN ( SELECT shadeID FROM sub_order_shades WHERE subOrderID IN ( SELECT id FROM sub_orders WHERE orderID IN ( SELECT id FROM orders WHERE oslNO = '".$oslNo."' ) ) ) )"); //echo $this->db->last_query();exit; return $query->result(); //print_r($dubba);exit; } public function get_po_tbl($subNo) { $this->db->from('planned_order'); $this->db->where('subNo', $subNo); $query = $this->db->get(); $result=$query->row(); $planningOrderID=$result->id; $this->db->from('po_plan`'); $this->db->where('planningOrderID', $planningOrderID); $query = $this->db->get(); return $query->result(); } public function getArticleID($shadeID){ $this->db->select('articleID'); $this->db->from('shade_master'); $this->db->where('shadeID', $shadeID); $query = $this->db->get(); return $query->row(); } public function getArticledetails($articleNumber){ $this->db->from('article_master'); $this->db->where('articleNo', $articleNumber); $query = $this->db->get(); //echo $this->db->last_query();exit; return $query->row(); } public function getWarpDetails($articleID,$shadeID){ $this->db->order_by('id','asc'); $this->db->from('warp_data'); $this->db->where('article_id', $articleID); $query = $this->db->get(); $details = $query->result_array(); return $details; } public function getWeftDetails($articleID,$shadeID){ $this->db->order_by('id','asc'); $this->db->from('weft_data'); $this->db->where('article_id', $articleID); $query = $this->db->get(); $details = $query->result_array(); return $details; } public function getWarpColors($shadeID){ $this->db->from('sm_warp'); $this->db->where('shadeID', $shadeID); $query = $this->db->get(); $details = $query->result_array(); return $details; } public function getWeftColors($shadeID){ $this->db->from('sm_weft'); $this->db->where('shadeID', $shadeID); $query = $this->db->get(); $details = $query->result_array(); return $details; } public function display_shadeTypeName($shadeType,$articleNo) { $query = $this->db->query('SELECT articleID FROM article_master where articleNo="' . $articleNo . '"'); $r=$query->row(); $articleID=$r->articleID; //echo'<pre>';print_r($query->row());exit; $query = $this->db->query('SELECT * FROM shade_master where shadeType="' . $shadeType . '" and articleID="' . $articleID . '"'); return $query->result(); } public function getallArticledata($id) { //$query = $this->db->query("SELECT article_master.articleNo,article_master.quality,article_master.design, //article_master.finishWidth,article_master.reedWidth,article_master.warpEnd,article_master.reed, //article_master.warpTotalEnds,article_master.weftPicks,article_master.finishedWeight,article_master.ratio,article_master.remark,article_master.finish_grams_squaremeter,article_master.pdffileupload FROM article_master INNER JOIN warp_data ON article_master.articleID=warp_data.article_id INNER JOIN weft_data ON article_master.articleID=weft_data.article_id WHERE article_master.articleID='$id'"); $query=$this->db->query("SELECT * FROM article_master WHERE articleID='$id'"); return $query->row(); } //update yarn rate here public function updateyarnrate($id,$rate) { $query = $this->db->query("UPDATE import_yarn SET rate='$rate' where id='$id'"); if($query) { return true; } else { return false; } } //display warping and wearing data public function display_warpwearing() { $query = $this->db->query("SELECT * FROM warping_wearing"); return $query->row(); } //update warping and wearing public function wwupdate($wwdata) { //$query = $this->db->update('warping_wearing', $wwdata, "id = 1"); $query=$this->db->update('warping_wearing', $wwdata, array('id' => '1')); if($query) { return true; } else { return false; } } public function designmasterdata() { $query = $this->db->get('design_master'); return $query->result(); } public function designmasterdata_row($id) { $this->db->select('*'); $this -> db ->from ('design_master'); $this->db->where('id',$id); $query=$this->db->get(); return $query->row(); } public function colormasterdata_row($id) { $this->db->select('*'); $this -> db ->from ('color_master'); $this->db->where('colorID',$id); $query=$this->db->get(); return $query->row(); } public function fabricmasterdata_row($id) { $this->db->select('*'); $this -> db ->from ('fabric_master'); $this->db->where('fabricID',$id); $query=$this->db->get(); return $query->row(); } public function shademasterdata_row($id) { $this->db->select('*'); $this -> db ->from ('shade_master'); $this->db->where('shadeID',$id); $query=$this->db->get(); return $query->row(); } public function fabricmasterdata() { $query = $this->db->get('fabric_master'); return $query->result(); } public function display_shadeTypeName1($shadeType,$result_article_id) { // //echo'<pre>';print_r($query->row());exit; $query = $this->db->query('SELECT * FROM shade_master where shadeType="' . $shadeType . '" and articleID="' . $result_article_id . '"'); return $query->result(); } public function delete($table,$where) { $this->db->where($where); $this->db->delete($table); } public function fetch_edit_data($where) { $this->db->select('*'); $this -> db ->from ('article_master'); //$this -> db->join ( 'jb_role r ', 'l.role=r.id'); $this->db->where($where); $query=$this->db->get(); return $query->row(); } public function dyeingplandetails($id) { $this->db->select('*'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'planned'); $this->db->where('o.id', $id); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('article_master am', 'am.articleNo = so.articleNo'); $this->db->join('warp_data wa', 'wa.article_id = am.articleID'); $this->db->join('weft_data we', 'we.article_id = am.articleID'); $this->db->join('planned_order po', 'po.oslNo = o.oslNo'); $this->db->join('sm_warp swa', 'swa.shadeID = sos.shadeID'); $this->db->join('sm_weft swe', 'swe.shadeID = sos.shadeID'); //$this->db->order_by("o.id", "desc"); //$this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function update_new($where,$table,$data) { $this->db->where($where); $this->db->update($table,$data); } public function get_planned_pending_orders() { $this->db->select('o.*,sos.planned_by,so.created_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'Pending'); $this->db->or_where('sos.planningStatus', 'planned'); $this->db->where('so.article_type', 'inhouse'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->order_by("o.id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function get_in_house_pending_shadeNo($orderID, $status) { $this->db->select('sos.*'); //$this->db->from('sub_orders so'); $this->db->from('sub_order_shades sos'); $this->db->join('sub_orders so', 'sos.subOrderID = so.id'); $this->db->where('so.article_type', 'inhouse'); $this->db->where('so.orderID', $orderID); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where($status); //$this->db->where('sos.planningStatus', 'planned'); $query = $this->db->get(); return $query->result(); } public function get_in_house_pending_shadeNo1($orderID) { $this->db->select('sos.*'); //$this->db->from('sub_orders so'); $this->db->from('sub_order_shades sos'); $this->db->join('sub_orders so', 'sos.subOrderID = so.id'); $this->db->where('so.article_type', 'inhouse'); $this->db->where('so.orderID', $orderID); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'planned'); $query = $this->db->get(); return $query->result(); } public function get_out_house_pending_shadeNum($orderID, $status) { $this->db->select('sos.*'); //$this->db->from('sub_orders so'); $this->db->from('sub_order_shades sos'); $this->db->join('sub_orders so', 'sos.subOrderID = so.id'); $this->db->where('so.article_type', 'outsource'); $this->db->where('so.orderID', $orderID); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planned_by !=',''); $this->db->where($status); //$this->db->where('sos.planningStatus', 'planned'); $query = $this->db->get(); return $query->result(); } //////////////////////////////// 1-6-2018 /////////////////////////////// public function get_planned_dyeing_pending_orders($y,$y1) { $this->db->select('o.*,sos.planned_by,so.created_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'Pending'); $this->db->or_where('sos.planningStatus', 'planned'); $this->db->where('so.article_type', 'inhouse'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('planned_order po', 'po.subNo = sos.shadeID'); $this->db->where('po.dyeingDate >=',$y); $this->db->where('po.dyeingDate <=',$y1); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function get_planned_dyeing_pending_orders1($y,$y1) { $this->db->select('o.*,sos.planned_by,so.created_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'Pending'); $this->db->or_where('sos.planningStatus', 'planned'); $this->db->where('so.article_type', 'inhouse'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('planned_order po', 'po.subNo = sos.shadeID'); $this->db->where('o.deliveryDate >=',$y); $this->db->where('o.deliveryDate <=',$y1); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function get_planned_dyeing_pending_orders2($y,$y1) { $this->db->select('o.*,sos.planned_by,so.created_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'Pending'); $this->db->or_where('sos.planningStatus', 'planned'); $this->db->where('so.article_type', 'inhouse'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('planned_order po', 'po.subNo = sos.shadeID'); $this->db->where('po.weavingDate >=',$y); $this->db->where('po.weavingDate <=',$y1); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function get_planned_dyeing_pending_orders3($y,$y1) { $this->db->select('o.*,sos.planned_by,so.created_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where('sos.planningStatus', 'Pending'); $this->db->or_where('sos.planningStatus', 'planned'); $this->db->where('so.article_type', 'inhouse'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('planned_order po', 'po.subNo = sos.shadeID'); $this->db->where('po.madeupDate >=',$y); $this->db->where('po.madeupDate <=',$y1); $this->db->order_by("id", "desc"); $this->db->group_by('oslNo'); $query = $this->db->get(); return $query->result(); } public function get_outsource_date_planning_orders($where,$y,$y1) { $this->db->select('o.*,sos.planned_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where($where); $this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('planned_order po', 'po.subNo = sos.shadeID'); $this->db->where('po.dyeingDate >=',$y); $this->db->where('po.dyeingDate <=',$y1); $this->db->group_by('oslNo'); $this->db->order_by("id", "desc"); $query = $this->db->get(); return $query->result(); } public function get_outsource_date_planning_orders1($where,$y,$y1) { $this->db->select('o.*,sos.planned_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where($where); $this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('planned_order po', 'po.subNo = sos.shadeID'); $this->db->where('o.deliveryDate >=',$y); $this->db->where('o.deliveryDate <=',$y1); $this->db->group_by('oslNo'); $this->db->order_by("id", "desc"); $query = $this->db->get(); return $query->result(); } public function get_outsource_date_planning_orders2($where,$y,$y1) { $this->db->select('o.*,sos.planned_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where($where); $this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('planned_order po', 'po.subNo = sos.shadeID'); $this->db->where('po.weavingDate >=',$y); $this->db->where('po.weavingDate <=',$y1); $this->db->group_by('oslNo'); $this->db->order_by("id", "desc"); $query = $this->db->get(); return $query->result(); } public function get_outsource_date_planning_orders3($where,$y,$y1) { $this->db->select('o.*,sos.planned_by'); $this->db->from('orders o'); $this->db->where('so.orderConfirm', 'Yes'); $this->db->where($where); $this->db->where('so.article_type', 'outsource'); $this->db->join('sub_orders so', 'so.orderID = o.id'); $this->db->join('sub_order_shades sos', 'sos.subOrderID = so.id'); $this->db->join('planned_order po', 'po.subNo = sos.shadeID'); $this->db->where('po.madeupDate >=',$y); $this->db->where('po.madeupDate <=',$y1); $this->db->group_by('oslNo'); $this->db->order_by("id", "desc"); $query = $this->db->get(); return $query->result(); } } ?>