You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.8 KiB
PHP
66 lines
1.8 KiB
PHP
<?php
|
|
|
|
class TempNewStoreInventory extends CI_Model
|
|
{
|
|
public $recordID;
|
|
public $brCode;
|
|
public $itemcode;
|
|
public $modelno;
|
|
public $qty;
|
|
public $sourceFilename;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->load->database();
|
|
}
|
|
|
|
|
|
public function getDataByBranchSourceFilename($brCode, $sourceFilename)
|
|
{
|
|
return $this->db->get_where("tempnewstoreinventory", array('brCode'=>$brCode, 'sourceFilename'=>$sourceFilename));
|
|
}
|
|
|
|
|
|
|
|
public function addNewMultipleData($data)
|
|
{
|
|
/*
|
|
should contain:
|
|
$data[0] = array('brCode'=>'','itemcode'=>'','modelno'=>'','qty'=>'','sourceFilename'=>'');
|
|
$data[1] = array('brCode'=>'','itemcode'=>'','modelno'=>'','qty'=>'','sourceFilename'=>'');
|
|
|
|
|
|
----------------- OLD CODE ---------------------
|
|
$sql = "INSERT INTO tempnewstoreinventory(brCode, itemcode, modelno, qty, sourceFilename) VALUES ";
|
|
|
|
foreach($data as $row)
|
|
$sql .= "('".$row["brCode"]."', ".$row["itemcode"].", '".$row["modelno"]."', ".$row["qty"].", '".$row["sourceFilename"]."'),";
|
|
|
|
//Remove extra comma at the end
|
|
$sql = substr($sql, 0, strlen($sql) - 1);
|
|
|
|
return $this->db->query($sql);
|
|
|
|
*/
|
|
|
|
|
|
return $this->db->insert_batch("tempnewstoreinventory", $data);
|
|
}
|
|
|
|
|
|
|
|
public function updateItemcodeFromItemsByBranchSourceFilename($brCode, $sourceFilename)
|
|
{
|
|
$sql = "UPDATE tempnewstoreinventory t JOIN items i ON t.modelno = i.modelno SET t.itemcode=i.itemcode WHERE t.brCode=? AND t.sourceFilename=?";
|
|
return $this->db->query($sql, array($brCode, $sourceFilename));
|
|
}
|
|
|
|
|
|
|
|
public function deleteByBranch($brCode)
|
|
{
|
|
return $this->db->delete("tempnewstoreinventory", array('brCode'=>$brCode));
|
|
}
|
|
} |