File: /home/mostafedeg/public_html/erp/models/mysql/ext/MProducthistoryMySqlExtDAO.class.php
<?php
/**
* Class that operate on table 'm_producthistory'. Database Mysql.
*
* @author: http://phpdao.com
* @date: 2014-09-07 16:06
*/
class MProducthistoryMySqlExtDAO extends MProducthistoryMySqlDAO{
public function GetStatusOfSerialWithMaxDate($ourSerial){
$sql = 'SELECT status ,stageFrom , m_stage.title as stageTitle
FROM m_producthistory
JOIN m_stage ON m_stage.id= m_producthistory.stageFrom
where ourSerial = ?
order by productHistoryDate DESC
LIMIT 0 , 1';
$sqlQuery = new SqlQuery($sql);
$sqlQuery->set($ourSerial);
//print_r($sqlQuery);
return $this->getRow($sqlQuery);
}
public function updatehistory($mProducthistory){
$sql = 'UPDATE m_producthistory SET stageFrom = ?, stageTo = ?, cost = ?, comment = ?, status = ?, userId = ?, productHistoryDate = ?, branchId = ?, del = ? WHERE ourSerial = ?';
$sqlQuery = new SqlQuery($sql);
$sqlQuery->setNumber($mProducthistory->stageFrom);
$sqlQuery->setNumber($mProducthistory->stageTo);
$sqlQuery->set($mProducthistory->cost);
$sqlQuery->setString2($mProducthistory->comment);
$sqlQuery->setNumber($mProducthistory->status);
$sqlQuery->setNumber($mProducthistory->userId);
$sqlQuery->set($mProducthistory->productHistoryDate);
$sqlQuery->setNumber($mProducthistory->branchId);
$sqlQuery->setNumber($mProducthistory->del);
$sqlQuery->set($mProducthistory->ourSerial);
return $this->executeUpdate($sqlQuery);
}
public function updatehistorydel($del,$ourSerial){
$sql = 'UPDATE m_producthistory SET del ='.$del.' WHERE ourSerial ="'.$ourSerial.'" ';
$sqlQuery = new SqlQuery($sql);
return $this->executeUpdate($sqlQuery);
}
public function loadserial($id){
$sql = 'SELECT * FROM m_producthistory WHERE ourSerial = "'.$id.'"';
//print_r("<br>".$sql);
$sqlQuery = new SqlQuery($sql);
return $this->getRow($sqlQuery);
}
public function updatehistorydelx($mProducthistory){
$sql = 'UPDATE m_producthistory SET userId = ?, productHistoryDate = ?, branchId = ?, del = ? WHERE productHistoryId = ?';
$sqlQuery = new SqlQuery($sql);
$sqlQuery->setNumber($mProducthistory->userId);
$sqlQuery->set($mProducthistory->productHistoryDate);
$sqlQuery->setNumber($mProducthistory->branchId);
$sqlQuery->setNumber($mProducthistory->del);
$sqlQuery->setNumber($mProducthistory->productHistoryId);
return $this->executeUpdate($sqlQuery);
}
public function getGeneralSearchData($ourSerials){
$sql = 'SELECT ourSerial,m_stagefrom.title as stageTitle,m_stageto.title as stageTitle2,cost,comment,status,productHistoryDate
FROM m_producthistory
JOIN m_stage as m_stagefrom ON m_stagefrom.id= m_producthistory.stageFrom
JOIN m_stage as m_stageto ON m_stageto.id= m_producthistory.stageTo
WHERE ourSerial in ('.$ourSerials.')
order by ourSerial asc,productHistoryId asc';
//print_r("<br/>".$sql."<br/>");
$sqlQuery = new SqlQuery($sql);
return $this->getList($sqlQuery);
}
}
?>