* adjust the company module. use dao.
This commit is contained in:
@@ -65,6 +65,7 @@ class company extends control
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->company->create();
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
die(js::locate($this->createLink('admin', 'browsecompany'), 'parent'));
|
||||
}
|
||||
|
||||
@@ -86,6 +87,7 @@ class company extends control
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->company->update($companyID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
die(js::locate($this->createLink('admin', 'browsecompany'), 'parent'));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,16 @@
|
||||
<?php
|
||||
class companyModel extends model
|
||||
{
|
||||
|
||||
/* <20><><EFBFBD>ò˵<C3B2><CBB5><EFBFBD>*/
|
||||
public function setMenu($dept = 0)
|
||||
{
|
||||
common::setMenuVars($this->lang->company->menu, 'addUser', array($this->app->company->id, $dept));
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>ù<EFBFBD>˾<EFBFBD>б<EFBFBD><D0B1><EFBFBD>*/
|
||||
function getList()
|
||||
public function getList()
|
||||
{
|
||||
$sql = "SELECT * FROM " . TABLE_COMPANY;
|
||||
$stmt = $this->dbh->query($sql);
|
||||
return $stmt->fetchAll();
|
||||
return $this->dao->select('*')->from(TABLE_COMPANY)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,40 +46,44 @@ class companyModel extends model
|
||||
*/
|
||||
public function getByDomain($domain = '')
|
||||
{
|
||||
if(empty($domain)) $domain = filter_input(INPUT_SERVER, 'HTTP_HOST');
|
||||
$sql = 'SELECT * FROM ' . TABLE_COMPANY . " WHERE `pms` = '$domain' LIMIT 1";
|
||||
return $this->dbh->query($sql)->fetch();
|
||||
if(empty($domain)) $domain = $_SERVER['HTTP_HOST'];
|
||||
return $this->dao->findByPMS($domain)->from(TABLE_COMPANY)->fetch();
|
||||
}
|
||||
|
||||
/* ͨ<><CDA8>id<69><64>ȡ<EFBFBD><C8A1>˾<EFBFBD><CBBE>Ϣ<EFBFBD><CFA2>*/
|
||||
public function getByID($companyID = '')
|
||||
{
|
||||
$sql = 'SELECT * FROM ' . TABLE_COMPANY . " WHERE `id` = '$companyID' LIMIT 1";
|
||||
return $this->dbh->query($sql)->fetch();
|
||||
return $this->dao->findById((int)$companyID)->from(TABLE_COMPANY)->fetch();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>˾<EFBFBD><CBBE>*/
|
||||
function create()
|
||||
public function create()
|
||||
{
|
||||
extract($_POST);
|
||||
$sql = "INSERT INTO " . TABLE_COMPANY . " (name, phone, fax, address, zipcode, website, backyard, pms, guest)
|
||||
VALUES('$name', '$phone', '$fax', '$address', '$zipcode', '$website', '$backyard', '$pms', '$guest')";
|
||||
return $this->dbh->exec($sql);
|
||||
$company = fixer::input('post')->get();
|
||||
$this->dao->insert(TABLE_COMPANY)
|
||||
->data($company)
|
||||
->autoCheck()
|
||||
->batchCheck('name, pms', 'notempty')
|
||||
->batchCheck('name,pms', 'unique')
|
||||
->exec();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>˾<EFBFBD><CBBE>Ϣ<EFBFBD><CFA2>*/
|
||||
function update($companyID)
|
||||
public function update($companyID)
|
||||
{
|
||||
extract($_POST);
|
||||
$sql = "UPDATE " . TABLE_COMPANY . " SET name = '$name', phone = '$phone', fax = '$fax', address = '$address',
|
||||
zipcode = '$zipcode', website = '$website', backyard = '$backyard', pms = '$pms', guest = '$guest'
|
||||
WHERE id = '$companyID' LIMIT 1";
|
||||
return $this->dbh->exec($sql);
|
||||
$company = fixer::input('post')->get();
|
||||
$this->dao->update(TABLE_COMPANY)
|
||||
->data($company)
|
||||
->autoCheck()
|
||||
->batchCheck('name, pms', 'notempty')
|
||||
->batchCheck('name,pms', 'unique', "id != '$companyID'")
|
||||
->where('id')->eq($companyID)
|
||||
->exec();
|
||||
}
|
||||
|
||||
/* ɾ<><C9BE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>˾<EFBFBD><CBBE>*/
|
||||
function delete($companyID)
|
||||
public function delete($companyID)
|
||||
{
|
||||
return $this->dbh->query("DELETE FROM " . TABLE_COMPANY . " WHERE id = '$companyID' LIMIT 1");
|
||||
return $this->dao->delete()->from(TABLE_COMPANY)->where('id')->eq((int)$companyID)->limit(1)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<div class='yui-d0'>
|
||||
<form method='post'>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table align='center' class='table-5'>
|
||||
<caption><?php echo $lang->company->create;?></caption>
|
||||
<tr>
|
||||
@@ -61,7 +61,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->company->guest;?></th>
|
||||
<td><?php echo html::radio('gust', $lang->company->guestList);?></td>
|
||||
<td><?php echo html::radio('guest', $lang->company->guestList);?></td>
|
||||
</tr>
|
||||
<tr><td colspan='2' class='a-center'><?php echo html::submitButton();?></td></tr>
|
||||
</table>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->company->guest;?></th>
|
||||
<td><?php echo html::radio('gust', $lang->company->guestList, $company->guest);?></td>
|
||||
<td><?php echo html::radio('guest', $lang->company->guestList, $company->guest);?></td>
|
||||
</tr>
|
||||
<tr><td colspan='2' class='a-center'><?php echo html::submitButton();?></td></tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user