public static function getShopByUser($userId, $roleId = 0, $shopId = 0) { $model = new Default_Model_Shops(); if ($roleId == 14) { $names = array(); $select = $model->getMapper()->getDbTable()->select()->from(array('s' => 'shops'), array('s.*'))->joinLeft(array('su' => 'district_manager_shops'), 's.id = su.idShop', array('suid' => 'su.id'))->where('NOT s.deleted')->where('su.idUser = ?', $userId)->setIntegrityCheck(false); $result = $model->fetchAll($select); if ($result) { foreach ($result as $value) { $names[] = $value->getName(); } } return implode(', ', $names); } else { $model->find($shopId); } return $model->getName(); }
public function save(Default_Model_Shops $value) { $auth = Zend_Auth::getInstance(); $authAccount = $auth->getStorage()->read(); if (null != $authAccount) { if (null != $authAccount->getId()) { $user = new Default_Model_Users(); $user->find($authAccount->getId()); $data = array('name' => $value->getName(), 'address' => $value->getAddress(), 'phoneNumber' => $value->getPhoneNumber(), 'company' => $value->getCompany(), 'cashBank' => $value->getCashBank(), 'creditCardBank' => $value->getCreditCardBank(), 'cashRegistry' => $value->getCashRegistry(), 'status' => $value->getStatus(), 'deleted' => '0'); if (null === ($id = $value->getId())) { $id = $this->getDbTable()->insert($data); //logs action done // $user_name = $user->name.' '.$user->surname; // $shop_name = $value->getName(); // $action_done = ' '.$user_name.' a adaugat shop-ul '.$shop_name.' '; //end logs action done } else { $this->getDbTable()->update($data, array('id = ?' => $id)); //logs action done // $user_name = $user->name.' '.$user->surname; // $shop_name = $value->getName(); // $action_done = ' '.$user_name.' a editat shop-ul '.$shop_name.' '; //end logs action done } return $id; } } }