Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com OrangeHRM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Beispiel #1
0
function loadCompany($jsonObject)
{
    $id = $jsonObject->id;
    // name
    $request = "SELECT * FROM company WHERE id = {$id}";
    $result = mysql_query($request);
    $row = mysql_fetch_object($result);
    $name = $row->name;
    // departments
    $departments = array();
    $request = "SELECT * FROM department WHERE cid = {$id} AND did IS NULL";
    $result = mysql_query($request);
    $count = mysql_num_rows($result);
    while ($row = mysql_fetch_object($result)) {
        $departments[] = $row->name;
    }
    // total
    $request = "SELECT * FROM employee";
    $result = mysql_query($request);
    $total = 0;
    while ($row = mysql_fetch_object($result)) {
        $total += $row->salary;
    }
    // create company object
    $company = new Company();
    $company->setDepartments($departments);
    $company->setName($name);
    $company->setTotal($total);
    // return company object
    return $company;
}
Beispiel #2
0
 public function addRelatedCompany(Company $rCompany)
 {
     if ($this->data['partIVA'] != '' && $this->data['partIVA'] != 0 && $rCompany->getRawData('partIVA') != '' && $rCompany->getRawData('partIVA') !== 0) {
         $this->db->query('INSERT IGNORE INTO `company_to_company` (`or_partIVA`,`dest_partIVA`,`titolo`) 
         VALUES("' . addslashes($this->data['partIVA']) . '","' . addslashes($rCompany->getRawData('partIVA')) . '","' . addslashes($rCompany->getRawData('titolo')) . '")', \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
     }
 }
Beispiel #3
0
 public function work()
 {
     $job = new Job();
     $job->getByUid($this->user->id);
     if ($job->hasWorked()) {
         throw new Exception('you have already worked');
     }
     $company = new Company();
     $company->get($job->company);
     //check if is in the same region
     if ($this->user->region != $company->region) {
         throw new Exception("You are not in the same region as company");
     }
     //check if company has funds enough
     if ($company->money < $job->salary) {
         throw new Exception("The company doesn't have funds enough");
     }
     $worked = $job->work();
     //add extra data before return
     if ($worked) {
         $data = $this->parse($job);
         $data = array_merge($data, $worked);
         return $data;
     } else {
         return false;
     }
 }
 public function updateCompany(Company $company)
 {
     $result = $this->companyDao->get($company->getId());
     ResultHelper::whenEmpty($result, AppLabelUtil::$ERROR_COMPANY_NOT_FOUND, HttpStatusCode::badRequest());
     $company->setStatus($this->validateStatus($company->getStatus()));
     $this->companyDao->update($company);
 }
Beispiel #5
0
 /**
  * Form builder
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  *
  * @return null
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->company = $options['company'];
     if (null == $this->company) {
         $builder->add('company', EntityType::class, array('label' => 'Docgroupcomptable.company.label', 'class' => 'AcfDataBundle:Company', 'query_builder' => function (CompanyRepository $br) {
             return $br->createQueryBuilder('c')->orderBy('c.corporateName', 'ASC');
         }, 'choice_label' => 'corporateName', 'multiple' => false, 'by_reference' => true, 'required' => true));
         $builder->add('parent', EntityType::class, array('label' => 'Docgroupcomptable.parent.label', 'class' => 'AcfDataBundle:Docgroupcomptable', 'query_builder' => function (DocgroupcomptableRepository $dgr) {
             return $dgr->createQueryBuilder('d')->orderBy('d.pageUrlFull', 'ASC');
         }, 'choice_label' => 'pageUrlFull', 'multiple' => false, 'by_reference' => true, 'required' => false, 'placeholder' => 'Options.choose', 'empty_data' => null));
         $builder->add('clone', EntityType::class, array('label' => 'Docgroup.clone.label', 'class' => 'AcfDataBundle:Docgroupcomptable', 'query_builder' => function (DocgroupcomptableRepository $dgr) {
             return $dgr->createQueryBuilder('d')->orderBy('d.pageUrlFull', 'ASC');
         }, 'choice_label' => 'pageUrlFull', 'multiple' => false, 'by_reference' => true, 'required' => false, 'placeholder' => 'Options.choose', 'mapped' => false));
     } else {
         $companyId = $this->company->getId();
         $builder->add('company', EntityidType::class, array('label' => 'Docgroupcomptable.company.label', 'class' => 'AcfDataBundle:Company', 'query_builder' => function (CompanyRepository $br) use($companyId) {
             return $br->createQueryBuilder('c')->where('c.id = :id')->setParameter('id', $companyId)->orderBy('c.corporateName', 'ASC');
         }, 'choice_label' => 'id', 'multiple' => false, 'by_reference' => true, 'required' => true));
         $builder->add('parent', EntityType::class, array('label' => 'Docgroupcomptable.parent.label', 'class' => 'AcfDataBundle:Docgroupcomptable', 'query_builder' => function (DocgroupcomptableRepository $dgr) use($companyId) {
             return $dgr->createQueryBuilder('d')->join('d.company', 'c')->where('c.id = :id')->setParameter('id', $companyId)->orderBy('d.pageUrlFull', 'ASC');
         }, 'choice_label' => 'pageUrlFull', 'multiple' => false, 'by_reference' => true, 'required' => false, 'placeholder' => 'Options.choose', 'empty_data' => null));
         $builder->add('clone', EntityType::class, array('label' => 'Docgroup.clone.label', 'class' => 'AcfDataBundle:Docgroupcomptable', 'query_builder' => function (DocgroupcomptableRepository $dgr) use($companyId) {
             return $dgr->createQueryBuilder('d')->join('d.company', 'c')->where('c.id = :id')->setParameter('id', $companyId)->orderBy('d.pageUrlFull', 'ASC');
         }, 'choice_label' => 'pageUrlFull', 'multiple' => false, 'by_reference' => true, 'required' => false, 'placeholder' => 'Options.choose', 'mapped' => false));
     }
     $builder->add('label', TextType::class, array('label' => 'Docgroupcomptable.label.label'));
     $builder->add('otherInfos', TextareaType::class, array('label' => 'Docgroupcomptable.otherInfos.label', 'required' => false));
 }
Beispiel #6
0
 /**
  * Form builder
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  *
  * @return null
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->company = $options['company'];
     if (null == $this->company) {
         $builder->add('company', EntityType::class, array('label' => 'Address.company.label', 'class' => 'AcfDataBundle:Company', 'query_builder' => function (CompanyRepository $br) {
             return $br->createQueryBuilder('c')->orderBy('c.corporateName', 'ASC');
         }, 'choice_label' => 'corporateName', 'multiple' => false, 'by_reference' => true, 'required' => true));
     } else {
         $companyId = $this->company->getId();
         $builder->add('company', EntityidType::class, array('label' => 'Address.company.label', 'class' => 'AcfDataBundle:Company', 'query_builder' => function (CompanyRepository $br) use($companyId) {
             return $br->createQueryBuilder('c')->where('c.id = :id')->setParameter('id', $companyId)->orderBy('c.corporateName', 'ASC');
         }, 'choice_label' => 'id', 'multiple' => false, 'by_reference' => true, 'required' => true));
     }
     $builder->add('label', TextType::class, array('label' => 'Address.label.label'));
     $builder->add('streetNum', IntegerType::class, array('label' => 'Address.streetNum.label', 'scale' => 0, 'required' => false));
     $builder->add('address', TextareaType::class, array('label' => 'Address.address.label', 'required' => false));
     $builder->add('address2', TextareaType::class, array('label' => 'Address.address2.label', 'required' => false));
     $builder->add('town', TextType::class, array('label' => 'Address.town.label', 'required' => false));
     $builder->add('zipCode', TextType::class, array('label' => 'Address.zipCode.label', 'required' => false));
     $builder->add('country', CountryType::class, array('label' => 'Address.country.label', 'required' => false, 'placeholder' => 'Options.choose', 'empty_data' => null));
     $builder->add('email', EmailType::class, array('label' => 'Address.email.label', 'required' => false));
     $builder->add('phone', TextType::class, array('label' => 'Address.phone.label', 'required' => false));
     $builder->add('mobile', TextType::class, array('label' => 'Address.mobile.label', 'required' => false));
     $builder->add('fax', TextType::class, array('label' => 'Address.fax.label', 'required' => false));
     $builder->add('otherInfos', TextareaType::class, array('label' => 'Address.otherInfos.label', 'required' => false));
 }
Beispiel #7
0
 static function getCompanyEmail($company_id)
 {
     // Get the email address for the company
     // Use the first Technical address that is not defined as name TICKET_SUPPORT
     //      TICKET_SUPPORT is defined in conf/config.php
     // If that does not exist, use the main address
     $config = Config::Instance();
     $contact = '';
     $company = new Company();
     $company->load($company_id);
     $party = $company->party;
     $sh = new SearchHandler(new PartyContactMethodCollection(new PartyContactMethod()), false);
     $sh->AddConstraint(new Constraint('type', '=', 'E'));
     $ticket_support = $config->get('TICKET_SUPPORT');
     if (!empty($ticket_support)) {
         $sh->AddConstraint(new Constraint('name', '!=', $ticket_support));
     }
     $party->addSearchHandler('contactmethods', $sh);
     $methods = $party->contactmethods;
     foreach ($methods as $method) {
         if ($method->technical == true) {
             // Technical contact favoured above all else
             $contact = $method->contact;
             break;
         }
         if ($method->main == true) {
             // If no contact yet found and this contact is the main contact, use this instead
             $contact = $method->contact;
         }
     }
     return $contact;
 }
Beispiel #8
0
 /**
  * Form builder
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  *
  * @return null
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->company = $options['company'];
     if (null == $this->company) {
         $builder->add('company', EntityType::class, array('label' => 'Supplier.company.label', 'class' => 'AcfDataBundle:Company', 'query_builder' => function (CompanyRepository $br) {
             return $br->createQueryBuilder('c')->orderBy('c.corporateName', 'ASC');
         }, 'choice_label' => 'corporateName', 'multiple' => false, 'by_reference' => true, 'required' => true));
     } else {
         $companyId = $this->company->getId();
         $builder->add('company', EntityidType::class, array('label' => 'Supplier.company.label', 'class' => 'AcfDataBundle:Company', 'query_builder' => function (CompanyRepository $br) use($companyId) {
             return $br->createQueryBuilder('c')->where('c.id = :id')->setParameter('id', $companyId)->orderBy('c.corporateName', 'ASC');
         }, 'choice_label' => 'id', 'multiple' => false, 'by_reference' => true, 'required' => true));
     }
     $builder->add('label', TextType::class, array('label' => 'Supplier.label.label'));
     $builder->add('number', IntegerType::class, array('label' => 'Supplier.number.label'));
     $builder->add('fisc', TextType::class, array('label' => 'Supplier.fisc.label', 'required' => false));
     $builder->add('physicaltype', ChoiceType::class, array('label' => 'Supplier.physicaltype.label', 'choices_as_values' => true, 'choices' => Supplier::choicePhysicaltype(), 'expanded' => true, 'attr' => array('choice_label_trans' => true)));
     $builder->add('cin', TextType::class, array('label' => 'Supplier.cin.label', 'required' => false));
     $builder->add('passport', TextType::class, array('label' => 'Supplier.passport.label', 'required' => false));
     $builder->add('commercialRegister', TextType::class, array('label' => 'Supplier.commercialRegister.label', 'required' => false));
     $builder->add('email', EmailType::class, array('label' => 'Supplier.email.label', 'required' => false));
     $builder->add('phone', TextType::class, array('label' => 'Supplier.phone.label', 'required' => false));
     $builder->add('mobile', TextType::class, array('label' => 'Supplier.mobile.label', 'required' => false));
     $builder->add('fax', TextType::class, array('label' => 'Supplier.fax.label', 'required' => false));
     $builder->add('streetNum', IntegerType::class, array('label' => 'Supplier.streetNum.label', 'scale' => 0, 'required' => false));
     $builder->add('address', TextareaType::class, array('label' => 'Supplier.address.label', 'required' => false));
     $builder->add('address2', TextareaType::class, array('label' => 'Supplier.address2.label', 'required' => false));
     $builder->add('town', TextType::class, array('label' => 'Supplier.town.label', 'required' => false));
     $builder->add('zipCode', TextType::class, array('label' => 'Supplier.zipCode.label', 'required' => false));
     $builder->add('country', CountryType::class, array('label' => 'Supplier.country.label', 'required' => false, 'placeholder' => 'Options.choose', 'empty_data' => null));
     $builder->add('otherInfos', TextareaType::class, array('label' => 'Supplier.otherInfos.label', 'required' => false));
 }
 public function _new()
 {
     parent::_new();
     $this->setTemplateName('calls_new');
     $projects = $opportunities = $activities = null;
     if (isset($this->_data['person_id'])) {
         $person = new Person();
         $person->load($this->_data['person_id']);
         $this->_data['company_id'] = $person->company_id;
         $projects = $person->projects;
         $opportunities = $person->opportunities;
         $activities = $person->activities;
         $this->view->set('person', $person->fullname);
     }
     if (isset($this->_data['company_id'])) {
         $company = new Company();
         $company->load($this->_data['company_id']);
         $projects = DataObjectCollection::Merge($company->projects, $projects);
         $opportunities = DataObjectCollection::Merge($company->opportunities, $opportunities);
         $activities = DataObjectCollection::Merge($company->activities, $activities);
         $this->view->set('company', $company->name);
     }
     if (isset($this->_data['project_id'])) {
         $project = new Project();
         $project->load($this->_data['project_id']);
         $this->_data['company_id'] = $project->company_id;
     }
     $this->view->set('projects', $projects);
     $this->view->set('opportunities', $opportunities);
     $this->view->set('activities', $activities);
 }
Beispiel #10
0
 public function actionAddcompany()
 {
     $companyModel = new Company();
     $userLoginModel = new UserLogin();
     $userProfileModel = new UserProfile();
     if (isset($_POST['Company'])) {
         $companyModel->attributes = $_POST['Company'];
         $userLoginModel->attributes = $_POST['UserLogin'];
         $userProfileModel->attributes = $_POST['UserProfile'];
         if ($companyModel->validate()) {
             if ($companyModel->save()) {
                 $userLoginModel->UserRoleID = 2;
                 // $userLoginModel->LoginEmail = '*****@*****.**';
                 $userLoginModel->UserPassword = md5($userLoginModel->UserPassword);
                 $userLoginModel->IsPasswordReset = 1;
                 $userLoginModel->IsActive = 1;
                 $userLoginModel->save();
                 $userProfileModel->UserLoginID = $userLoginModel->UserLoginID;
                 $userProfileModel->CompanyID = $companyModel->CompanyID;
                 // $userProfileModel->FirstName = 'Test';
                 // $userProfileModel->LastName = 'test';
                 $userProfileModel->AgreeToTerms = 0;
                 $userProfileModel->IsFacilitator = 0;
                 $userProfileModel->save();
                 $this->redirect(Yii::app()->createUrl('admin/setup', array('id' => $companyModel->CompanyID)));
             }
         }
     }
     $this->render('add-company', array('companyModel' => $companyModel, 'userLoginModel' => $userLoginModel, 'userProfileModel' => $userProfileModel));
 }
 public function createAndSaveMultipleCompanies($count)
 {
     for ($i = 65; $i <= 65 + $count - 1; $i++) {
         $company = new Company();
         $company->setName(sprintf($this->getCreatedCompanynamePattern(), chr($i)));
         $company->save();
     }
 }
Beispiel #12
0
 function getCompany($companyID)
 {
     $company = new Company();
     if ($company->selectRecord($companyID)) {
         return $company;
     } else {
         return false;
     }
 }
function encoder_redirect_success(Company $company)
{
    $Company_Name = $company->getCompanyName();
    $Company_Name_Amharic = $company->getCompanyNameAmharic();
    $dir = "VIEW/html/Encoder/Add_Company/Company_List.php?success=1&Company_Name={$Company_Name}&Company_Name_Amharic={$Company_Name_Amharic}";
    $url = BASE_URL . $dir;
    header("Location:{$url}");
    //redirect the encoder to the regions add place
    exit;
}
Beispiel #14
0
 function updateCompany($xmlStr)
 {
     if (!($domDoc = domxml_open_mem($xmlStr))) {
         return false;
     }
     $company = new Company();
     $company->parseDomDocument($domDoc);
     $ret = $company->updateRecord();
     return $ret;
 }
Beispiel #15
0
 function display()
 {
     Load::model('company');
     $Company = new Company();
     $param['income'] = $Company->get_income();
     $param['expense'] = $Company->get_expense();
     //$param['onhand'] = $this->get_cashonhand();
     //$param['aff_money'] = $this->get_affmoney();
     Load::view('business-status', $param);
 }
Beispiel #16
0
 function getCompanyDetails($companyID)
 {
     $company = new Company();
     $company->selectRecord($companyID);
     if (!($domDoc = $company->getDomDocument())) {
         return false;
     } else {
         $xmlStr = $domDoc->dump_mem(true);
         return $xmlStr;
     }
 }
Beispiel #17
0
 function selectRecords($condition = " ORDER BY TRIM(Company.companyName) ASC LIMIT 0,10")
 {
     $this->setDB();
     $sql = sprintf("SELECT DISTINCT(OwnerCompany.companyID) as companyID" . " FROM OwnerCompany,Company " . " WHERE OwnerCompany.companyID = Company.companyID " . " %s;", $condition);
     $this->db->query($sql);
     while ($this->db->next_record()) {
         $company = new Company();
         $company->selectRecord($this->db->f("companyID"));
         $this->arrayList[] = $company;
     }
 }
Beispiel #18
0
 public function company()
 {
     $userid = self::get_user();
     $company = new Company($userid);
     $compdata = $company->currentcompany();
     while ($rowscomp = $compdata->fetch_object()) {
         $this->companydata[] = $rowscomp;
     }
     // echo "<pre>";
     // var_dump($this->companydata);exit;
 }
Beispiel #19
0
 public static function map(Company $company, array $properties)
 {
     if (array_key_exists('company_id', $properties)) {
         $company->setCompany_id((int) $properties['company_id']);
     }
     if (array_key_exists('company_img_url', $properties)) {
         $company->setCompany_img_url($properties['company_img_url']);
     }
     if (array_key_exists('company_name', $properties)) {
         $company->setCompany_name($properties['company_name']);
     }
 }
Beispiel #20
0
 function Main($referer = "")
 {
     if (!$referer || !isset($referer)) {
         $referer = "OwnerList.php";
     }
     $this->tpl->set_var("referer", $referer);
     switch ($this->formArray["formAction"]) {
         case "save" || "view" || "viewOnly":
             $this->tpl->set_var("referer", $referer);
             $CompanyDetails = new SoapObject(NCCBIZ . "CompanyDetails.php", "urn:Object");
             if (!($xmlStr = $CompanyDetails->getCompanyDetails($this->formArray["companyID"]))) {
                 $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                 $this->tpl->set_var("TableBlock", "record not found");
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                     $this->tpl->set_var("TableBlock", "error xmlDoc");
                 } else {
                     $company = new Company();
                     $company->parseDomDocument($domDoc);
                     $this->formArray["companyID"] = $company->getCompanyID();
                     $this->formArray["companyName"] = $company->getCompanyName();
                     $this->formArray["tin"] = $company->getTin();
                     $this->formArray["telephone"] = $company->getTelephone();
                     $this->formArray["fax"] = $company->getFax();
                     $address = $company->addressArray[0];
                     if (is_a($address, Address)) {
                         $this->formArray["addressID"] = $address->getAddressID();
                         $this->formArray["number"] = $address->getNumber();
                         $this->formArray["street"] = $address->getStreet();
                         $this->formArray["barangay"] = $address->getBarangay();
                         $this->formArray["district"] = $address->getDistrict();
                         $this->formArray["municipalityCity"] = $address->getMunicipalitycity();
                         $this->formArray["province"] = $address->getProvince();
                     }
                     $this->formArray["email"] = $company->getEmail();
                     $this->formArray["website"] = $company->getWebsite();
                 }
             }
             if ($this->formArray["formAction"] == "viewOnly") {
                 $this->tpl->set_block("rptsTemplate", "ViewOnly", "ViewOnlyBlock");
                 $this->tpl->set_var("ViewOnlyBlock", "");
             }
             break;
         case "cancel":
             //header("location: CompanyList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock");
             $this->tpl->set_var("ACKBlock", "");
     }
     //*/
     $this->setForm();
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }
 public function mapDtoToCompany(CompanyDto $companyDto)
 {
     $company = new Company();
     $company->setId($companyDto->getId());
     $company->setName($companyDto->getName());
     $company->setContactName($companyDto->getContactName());
     $company->setEmail($companyDto->getEmail());
     $company->setPhoneNumber($companyDto->getPhoneNumber());
     $company->setRegion($companyDto->getRegion());
     $company->setWebsite($companyDto->getWebsite());
     $company->setStatus($companyDto->getStatus());
     return $company;
 }
 /**
  * @param int $id
  * @param string $name
  * @param string $contactname
  * @param string $email
  * @param string $phonenumber
  * @param string $region
  * @param string $website
  * @param int $status
  * @return Company
  */
 public static function createCompany($id, $name, $contactname, $email, $phonenumber, $region, $website, $status)
 {
     $newCompany = new Company();
     $newCompany->setId($id);
     $newCompany->setName($name);
     $newCompany->setContactName($contactname);
     $newCompany->setEmail($email);
     $newCompany->setPhoneNumber($phonenumber);
     $newCompany->setRegion($region);
     $newCompany->setWebsite($website);
     $newCompany->setStatus($status);
     return $newCompany;
 }
Beispiel #23
0
 public function getList()
 {
     if (!empty($_REQUEST['uid'])) {
         $uid = (int) $_REQUEST['uid'];
         $where = array(array('uid', '=', $uid));
         $companyClass = new Company();
         $companyList = $companyClass->find($where);
         foreach ($companyList as $k => $company) {
             $companyList[$k] = $this->parse($company);
         }
         return $companyList;
     }
 }
Beispiel #24
0
 /**
  * create new company & user as creator & admin
  */
 public function register()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         //create company first
         $company = new Company();
         $company->name = $this->name;
         $company->country = $this->country;
         $company->phone = $this->phone;
         if (!$company->save()) {
             $transaction->rollback();
             return false;
         }
         //create user
         $user = new User();
         $user->username = $this->username;
         $user->password = $user->encrypt($this->password);
         $user->password_repeat = $this->password_repeat;
         $user->email = $this->email;
         $user->company_id = $company->id;
         $user->create_time_utc = $user->update_time_utc = time();
         if (!$user->save(false)) {
             $transaction->rollback();
             return false;
         }
         $company->owner_id = $company->create_user_id = $company->update_user_id = $user->id;
         if (!$company->update()) {
             $transaction->rollback();
             return false;
         }
         $user->create_user_id = $user->update_user_id = $user->id;
         if (!$user->update()) {
             $transaction->rollback();
             return false;
         }
         //create default product folder
         $defaultProductFolder = new ProductFolder();
         $defaultProductFolder->name = 'Main Folder';
         $defaultProductFolder->parent_id = 0;
         $defaultProductFolder->company_id = $company->id;
         if (!$defaultProductFolder->save()) {
             $transaction->rollback();
             return false;
         }
         $transaction->commit();
         return true;
     } catch (Exception $ex) {
         $transaction->rollback();
         return false;
     }
 }
Beispiel #25
0
 public function _new()
 {
     parent::_new();
     $ticket = $this->_uses[$this->modeltype];
     if (isset($this->_data['originator_company_id'])) {
         $company = new Company();
         $company->load($this->_data['originator_company_id']);
         $this->view->set('originator_company', $company->name);
         $this->view->set('people', $company->getPeople());
         $this->view->set('email', Ticket::getCompanyEmail($this->_data['originator_company_id']));
     } else {
         $company = new Systemcompany();
         $company->load(EGS_COMPANY_ID);
         $this->view->set('originator_company', $company->company);
         $this->view->set('people', $company->systemcompany->getPeople());
     }
     $ticketreleaseversion = new TicketReleaseVersion();
     $releaseversion_cc = new ConstraintChain();
     $releaseversion_cc->add(new Constraint('status', '<>', $ticketreleaseversion->releasedStatus()));
     if (!$ticket->isLoaded()) {
         $defaults = new TicketConfiguration();
         if (isset($this->_data['originator_company_id'])) {
             $cc = new ConstraintChain();
             $cc->add(new Constraint('company_id', '=', $this->_data['originator_company_id']));
             $defaults->loadBy($cc);
         }
         if (!$defaults->isLoaded()) {
             $cc = new ConstraintChain();
             $cc->add(new Constraint('company_id', '=', EGS_COMPANY_ID));
             $defaults->loadBy($cc);
         }
         if ($defaults->isLoaded()) {
             $this->view->set('client_ticket_status_default', $defaults->client_ticket_status_id);
             $this->view->set('internal_ticket_status_default', $defaults->internal_ticket_status_id);
             $this->view->set('ticket_queue_default', $defaults->ticket_queue_id);
             $this->view->set('ticket_category_default', $defaults->ticket_category_id);
             $this->view->set('client_ticket_severity_default', $defaults->client_ticket_severity_id);
             $this->view->set('internal_ticket_severity_default', $defaults->internal_ticket_severity_id);
             $this->view->set('client_ticket_priority_default', $defaults->client_ticket_priority_id);
             $this->view->set('internal_ticket_priority_default', $defaults->internal_ticket_priority_id);
         }
     }
     if (!empty($this->_data['ticket_release_version_id'])) {
         $ticket->ticket_release_version_id = $this->_data['ticket_release_version_id'];
     }
     if (!is_null($ticket->ticket_release_version_id)) {
         $releaseversion_cc->add(new Constraint('id', '=', $ticket->ticket_release_version_id), 'OR');
     }
     $ticket->belongsTo['release_version']['cc'] = $releaseversion_cc;
 }
Beispiel #26
0
 function Main()
 {
     switch ($this->formArray["ownerType"]) {
         case "Person":
             $this->tpl->set_block("rptsTemplate", "CompanyDetails", "CompanyDetailsBlock");
             $this->tpl->set_var("CompanyDetailsBlock", "");
             $person = new Person();
             $person->selectRecord($this->formArray["id"]);
             $this->tpl->set_var("id", $person->getPersonID());
             $this->tpl->set_var("lastName", $person->getLastName());
             $this->tpl->set_var("firstName", $person->getFirstName());
             $this->tpl->set_var("middleName", $person->getMiddleName());
             $this->tpl->set_var("gender", $person->getGender());
             $this->tpl->set_var("birthday", $person->getBirthday());
             $this->tpl->set_var("maritalStatus", $person->getMaritalStatus());
             $this->tpl->set_var("tin", $person->getTin());
             $address = $person->addressArray[0];
             if (is_a($address, Address)) {
                 $this->tpl->set_var("fullAddress", $address->getFullAddress());
             }
             $this->tpl->set_var("telephone", $person->getTelephone());
             $this->tpl->set_var("mobileNumber", $person->getMobileNumber());
             $this->tpl->set_var("email", $person->getEmail());
             break;
         case "Company":
             $this->tpl->set_block("rptsTemplate", "PersonDetails", "PersonDetailsBlock");
             $this->tpl->set_var("PersonDetailsBlock", "");
             $company = new Company();
             $company->selectRecord($this->formArray["id"]);
             $this->tpl->set_var("id", $company->getCompanyID());
             $this->tpl->set_var("companyName", $company->getCompanyName());
             $this->tpl->set_var("tin", $company->getTin());
             $this->tpl->set_var("telephone", $company->getTelephone());
             $this->tpl->set_var("fax", $company->getFax());
             $address = $company->addressArray[0];
             if (is_a($address, Address)) {
                 $this->tpl->set_var("fullAddress", $address->getFullAddress());
             }
             $this->tpl->set_var("email", $company->getEmail());
             $this->tpl->set_var("website", $company->getWebsite());
             break;
         default:
             exit("No Person/Company selected. <a href='OwnerList.php" . $this->sess->url("") . "'>Click here</a> to go back to the Owner List.");
             break;
     }
     $this->tpl->set_var("ownerType", $this->formArray["ownerType"]);
     $this->tpl->set_var("uname", $this->user["uname"]);
     $this->tpl->set_var("today", date("F j, Y"));
     $this->setPageDetailPerms();
     $this->tpl->set_var("Session", $this->sess->url(""));
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }
Beispiel #27
0
 /**
  * Form builder
  *
  * @param FormBuilderInterface $builder
  * @param array $options
  *
  * @return null
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $this->company = $options['company'];
     if (null == $this->company) {
         $builder->add('company', EntityType::class, array('label' => 'CompanyFrame.company.label', 'class' => 'AcfDataBundle:Company', 'query_builder' => function (CompanyRepository $br) {
             return $br->createQueryBuilder('c')->orderBy('c.corporateName', 'ASC');
         }, 'choice_label' => 'corporateName', 'multiple' => false, 'by_reference' => true, 'required' => true));
     } else {
         $companyId = $this->company->getId();
         $builder->add('company', EntityidType::class, array('label' => 'CompanyFrame.company.label', 'class' => 'AcfDataBundle:Company', 'query_builder' => function (CompanyRepository $br) use($companyId) {
             return $br->createQueryBuilder('c')->where('c.id = :id')->setParameter('id', $companyId)->orderBy('c.corporateName', 'ASC');
         }, 'choice_label' => 'id', 'multiple' => false, 'by_reference' => true, 'required' => true));
     }
     $builder->add('year', IntegerType::class, array('label' => 'MBSale.year.label'));
 }
Beispiel #28
0
 public function createUser(RegistrationForm $form)
 {
     $transaction = Yii::app()->getDb()->beginTransaction();
     try {
         $user = new User();
         $password = rand(1000000, 9999999);
         $Company = new Company();
         if ($form->organization_name) {
             $Company->name = $form->organization_name;
         }
         $Company->create = new CDbExpression('NOW()');
         $Company->save();
         $user->email = $form->email;
         $user->contact_phone = $form->phone;
         $user->contact_phone_prefix = $form->prefphone;
         $user->company_id = $Company->id;
         $user->status = User::STATUS_ACTIVE;
         //Сделать автопроверку выписки
         $user->setAttribute('hash', $this->hasher->hashPassword($password));
         if ($user->save() && ($token = $this->tokenStorage->createAccountActivationToken($user)) !== false) {
             $user->sendCRMRegistration();
             User::savePost($user);
             \Yii::import('application.modules.rbac.models.*');
             $model = new AuthAssignment();
             //$model->setAttributes(['userid' => $user->id,'itemname' => 'standart']); //Назаначаем роль владельца компании без инн
             //                $model->setAttributes(['userid' => $user->id,'itemname' => 'own_wo_inn']); //Назаначаем роль владельца компании без инн
             $model->setAttributes(['userid' => $user->id, 'itemname' => 'owner']);
             //Назаначаем роль владельца компании без инн
             if (!$model->save()) {
                 throw new CDbException(Yii::t('UserModule.rbac', 'There is an error occurred when saving data!'));
             }
             Yii::app()->eventManager->fire(UserEvents::SUCCESS_REGISTRATION, new UserRegistrationEvent($form, $user, $token, $password));
             Yii::log(Yii::t('UserModule.user', 'Account {nick_name} was created', ['{nick_name}' => $user->email]), CLogger::LEVEL_INFO, UserModule::$logCategory);
             $transaction->commit();
             $LoginForm = new LoginForm();
             $LoginForm->email = $user->email;
             $LoginForm->password = $password;
             Yii::app()->authenticationManager->login($LoginForm, Yii::app()->getUser(), Yii::app()->getRequest());
             return $user;
         }
         throw new CException(Yii::t('UserModule.user', 'Error creating account!'));
     } catch (Exception $e) {
         Yii::log(Yii::t('UserModule.user', 'Error {error} account creating!', ['{error}' => $e->__toString()]), CLogger::LEVEL_INFO, UserModule::$logCategory);
         $transaction->rollback();
         Yii::app()->eventManager->fire(UserEvents::FAILURE_REGISTRATION, new UserRegistrationEvent($form, $user));
         return false;
     }
 }
Beispiel #29
0
 public function filter()
 {
     if (!isset($this->user) || !$this->user || $this->user == parent::ANONYMOUS_USER) {
         return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
     }
     if (!$this->user->can('item_delete')) {
         return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
     }
     //$company_id = Request::segment(3);
     $company_id = Input::get('company_id');
     $id = Request::segment(3);
     $company = Company::with('items')->find($company_id);
     if (!$company) {
         return Response::json(['error' => true, 'error_description' => 'Company not found'], 400);
     }
     $find = 0;
     foreach ($company->items as $item) {
         if ($item->id == $id) {
             $find = 1;
         }
     }
     if (!$find) {
         return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
     }
 }
 public function all()
 {
     if (\KodeInfo\Utilities\Utils::isDepartmentAdmin(Auth::user()->id)) {
         $department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first();
         $department = Department::where('id', $department_admin->department_id)->first();
         $company = Company::where('id', $department->company_id)->first();
         $messages = CannedMessages::where('company_id', $company->id)->where('department_id', $department->id)->orderBy('id', 'desc')->get();
     } elseif (\KodeInfo\Utilities\Utils::isOperator(Auth::user()->id)) {
         $department_admin = OperatorsDepartment::where('user_id', Auth::user()->id)->first();
         $department = Department::where('id', $department_admin->department_id)->first();
         $company = Company::where('id', $department->company_id)->first();
         $messages = CannedMessages::where('company_id', $company->id)->where('department_id', $department->id)->where('operator_id', Auth::user()->id)->orderBy('id', 'desc')->get();
     } else {
         $messages = CannedMessages::orderBy('id', 'desc')->get();
     }
     foreach ($messages as $message) {
         $operator = User::find($message->operator_id);
         $department = Department::find($message->department_id);
         $company = Company::find($message->company_id);
         $message->operator = $operator;
         $message->department = $department;
         $message->company = $company;
     }
     $this->data['messages'] = $messages;
     return View::make('canned_messages.all', $this->data);
 }