Exemplo n.º 1
0
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Phalcon_Model_Query::fromInput("Companies", $_POST);
         $this->session->conditions = $query->getConditions();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($this->session->conditions) {
         $parameters["conditions"] = $this->session->conditions;
     }
     $parameters["order"] = "id";
     $companies = Companies::find($parameters);
     if (count($companies) == 0) {
         Flash::notice("The search did not find any companies", "alert alert-info");
         return $this->_forward("companies/index");
     }
     $paginator = Phalcon_Paginator::factory("Model", array("data" => $companies, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     $this->view->setVar("companies", $companies);
 }
Exemplo n.º 2
0
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Companies", $_POST);
         $this->persistent->searchParams = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($this->persistent->searchParams) {
         $parameters = $this->persistent->searchParams;
     }
     $companies = Companies::find($parameters);
     if (count($companies) == 0) {
         $this->flash->notice("The search did not find any companies");
         return $this->forward("companies/index");
     }
     $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $companies, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     $this->view->setVar("companies", $companies);
 }
 /**
  * Searches for companies
  */
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Companies", $_POST);
         $this->persistent->parameters = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
     }
     $parameters = $this->persistent->parameters;
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $parameters["order"] = "id";
     $companies = Companies::find($parameters);
     if (count($companies) == 0) {
         $this->flash->notice("The search did not find any companies");
         return $this->dispatcher->forward(array("controller" => "companies", "action" => "index"));
     }
     $paginator = new Paginator(array("data" => $companies, "limit" => 10, "page" => $numberPage));
     $this->view->page = $paginator->getPaginate();
 }
 /**
  * Return owner company from database
  *
  * @param void
  * @return Company
  */
 function findOwnerCompany()
 {
     return Companies::find(array('conditions' => array('is_owner = ?', true), 'one' => true));
 }
Exemplo n.º 5
0
 public function getDelete($id = '')
 {
     if ($id == '') {
         return Redirect::to($this->route)->with('msg_error', Lang::get('messages.companies_display_err'));
     } else {
         $company = Companies::find($id);
         $delete = Companies::destroy($id);
         if (!$delete) {
             return Redirect::to($this->route . '/trash')->with('msg_error', Lang::get('messages.companies_delete_err', array('title' => $company->title)));
         } else {
             return Redirect::to($this->route . '/trash')->with('msg_success', Lang::get('messages.companies_delete', array('title' => $company->title)));
         }
     }
 }
 /**
  * Form for POST doDelete the specified resource.
  *
  * @return Response
  */
 public function doDelete()
 {
     $aData = Input::all();
     if (isset($aData['id'])) {
         $company = Companies::find($aData['id']);
         $company->delete();
         return Redirect::route('company-list')->with('message', 'Компания успешно удален');
     }
     return Redirect::route('company-list')->with('message', 'Произошла ошибка удаления');
 }
Exemplo n.º 7
0
use backend\models\companies;
/* @var $this yii\web\View */
/* @var $model backend\models\Branches */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="branches-form">

    <?php 
$form = ActiveForm::begin();
?>



    <?php 
echo $form->field($model, 'companies_company_id')->dropDownList(ArrayHelper::map(Companies::find()->all(), 'company_id', 'company_name'), ['promp' => 'Select Company']);
?>

    <?php 
echo $form->field($model, 'branch_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'branch_address')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'branch_status')->dropDownList(['active' => 'Active', 'inactive' => 'Inactive'], ['prompt' => 'Status']);
?>

    <div class="form-group">