public function init() { $this->setAttrib('class', 'horizontal-form')->setName('search'); $elements = array(); $elements[] = $this->createElement('text', 'campaign_title')->setDecorators($this->getDefaultElementDecorators())->addFilter('StringTrim')->addFilter('StringToUpper')->setAttrib('maxlength', 200)->setAttrib('class', 'm-wrap span12 focused')->setLabel('Naran Kampanha'); $dbCampaignType = App_Model_DbTable_Factory::get('CampaignType'); $rows = $dbCampaignType->fetchAll(array(), array('campaign_type')); $optCampaignType[''] = ''; foreach ($rows as $row) { $optCampaignType[$row->id_campaign_type] = $row->campaign_type; } $elements[] = $this->createElement('select', 'fk_id_campaign_type')->setDecorators($this->getDefaultElementDecorators())->setLabel('Tipu Kampanha')->addMultiOptions($optCampaignType)->setAttrib('class', 'm-wrap span12 chosen'); $mapperDepartment = new Admin_Model_Mapper_Department(); $rows = $mapperDepartment->fetchAll(); $optDepartment[''] = ''; foreach ($rows as $row) { $optDepartment[$row->id_department] = $row->name; } $elements[] = $this->createElement('select', 'fk_id_department')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Departamentu')->addMultiOptions($optDepartment); $mapperGroup = new Sms_Model_Mapper_Group(); $rows = $mapperGroup->fetchAll(); $optGroups = array(); foreach ($rows as $row) { $optGroups[$row['id_sms_group']] = $row['sms_group_name']; } $elements[] = $this->createElement('multiCheckbox', 'group')->setDecorators(array('ViewHelper'))->addMultiOptions($optGroups)->setAttrib('class', 'group-sending')->setRequired(true)->setSeparator(''); $view = $this->getView(); $optStatuses = $view->campaign()->getStatuses(); array_unshift($optStatuses, ''); $elements[] = $this->createElement('select', 'status')->setDecorators($this->getDefaultElementDecorators())->addMultiOptions($optStatuses)->setLabel('Status')->setAttrib('class', 'm-wrap span12'); $this->addElements($elements); }
/** * */ public function init() { parent::init(); $this->removeElement('fk_id_dec'); $elements = array(); $elements[] = $this->createElement('hidden', 'path')->setAttrib('class', 'no-clear')->setValue('sms/sending-report')->setDecorators(array('ViewHelper')); $elements[] = $this->createElement('hidden', 'title')->setAttrib('class', 'no-clear')->setValue('Relatoriu: Enviu sira')->setDecorators(array('ViewHelper')); $elements[] = $this->createElement('hidden', 'orientation')->setValue('landscape')->setAttrib('class', 'no-clear')->setDecorators(array('ViewHelper')); $mapperDepartment = new Admin_Model_Mapper_Department(); $rows = $mapperDepartment->fetchAll(); $optDepartment[''] = ''; foreach ($rows as $row) { $optDepartment[$row->id_department] = $row->name; } $elements[] = $this->createElement('select', 'fk_id_department')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Departamentu')->addMultiOptions($optDepartment); $mapperCampaign = new Sms_Model_Mapper_Campaign(); $rows = $mapperCampaign->listByFilters(); $optCampaign[''] = ''; foreach ($rows as $row) { $optCampaign[$row->id_campaign] = $row->campaign_title; } $elements[] = $this->createElement('select', 'fk_id_campaign')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Kampanha')->addMultiOptions($optCampaign); $optStatus[''] = ''; $optStatus['E'] = 'Sala'; $optStatus['S'] = 'Loos'; $elements[] = $this->createElement('select', 'status_sending')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span6')->setLabel('Status enviu')->addMultiOptions($optStatus); $this->addElements($elements); }
public function init() { $this->setAttrib('class', 'horizontal-form'); $elements = array(); $mapperDepartment = new Admin_Model_Mapper_Department(); $departments = $mapperDepartment->fetchAll(); $optDepartments[''] = ''; foreach ($departments as $user) { $optDepartments[$user['id_department']] = $user['name']; } $elements[] = $this->createElement('select', 'fk_id_department')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Departamentu')->addMultiOptions($optDepartments)->setRequired(true); $elements[] = $this->createElement('text', 'value')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span4 money-mask')->setLabel('Folin Hira')->setRequired(true); $elements[] = $this->createElement('text', 'amount')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span4 text-numeric')->setLabel('Hira')->setRequired(true); $this->addElements($elements); App_Form_Toolbar::build($this, self::ID); $this->setDecorators($this->getDefaultFormDecorators()); }
/** * */ public function init() { parent::init(); $this->removeElement('fk_id_dec'); $elements = array(); $elements[] = $this->createElement('hidden', 'path')->setAttrib('class', 'no-clear')->setValue('sms/credit-report')->setDecorators(array('ViewHelper')); $elements[] = $this->createElement('hidden', 'title')->setAttrib('class', 'no-clear')->setValue('Relatoriu: Pulsa Departamentu')->setDecorators(array('ViewHelper')); $mapperDepartment = new Admin_Model_Mapper_Department(); $rows = $mapperDepartment->fetchAll(); $optDepartment[''] = ''; foreach ($rows as $row) { $optDepartment[$row->id_department] = $row->name; } $elements[] = $this->createElement('select', 'fk_id_department')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Departamentu')->addMultiOptions($optDepartment); $dbUser = App_Model_DbTable_Factory::get('SysUser'); $rows = $dbUser->fetchAll(array(), array('name')); $users[''] = ''; foreach ($rows as $row) { $users[$row->id_sysuser] = $row->name . ' (' . $row->login . ')'; } $elements[] = $this->createElement('select', 'fk_id_sysuser')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Uzuariu mak halo')->addMultiOptions($users); $this->addElements($elements); }
/** * */ public function listAction() { $this->_helper->layout()->disableLayout(); $this->view->rows = $this->_mapper->fetchAll(); }
/** * * @return boolean */ protected function _validateDepartment() { $user = Zend_Auth::getInstance()->getIdentity(); $mapperDepartment = new Admin_Model_Mapper_Department(); $department = $mapperDepartment->getDepartmentByUser($user->id_sysuser); // If there is no department if (empty($department)) { $this->addMessage('Ita la bele rejistu kampanha SMS. Tenki husu uzuariu husi departamentu'); return false; } $this->_department = $department; return true; }
/** * */ public function calcSendingAction() { $user = Zend_Auth::getInstance()->getIdentity(); // Get the User department $mapperDepartment = new Admin_Model_Mapper_Department(); $department = $mapperDepartment->getDepartmentByUser($user->id_sysuser); // Get the groups with totals $mapperGroupsSms = new Sms_Model_Mapper_Group(); $groups = $mapperGroupsSms->listGroupWithTotals(); // Get the current sms config $mapperConfig = new Admin_Model_Mapper_SmsConfig(); $config = $mapperConfig->getConfig(); $groupsSelected = $this->_getParam('groups'); $total = 0; $percent = 100; if (!empty($groupsSelected)) { foreach ($groups as $group) { if (in_array($group['id_sms_group'], $groupsSelected)) { $total += (int) $group['total']; } } } $totalCurrency = $total * (double) $config->sms_unit_cost; if (!empty($department['balance'])) { $percent = $totalCurrency * 100 / $department['balance']; } $return = array('total' => $total, 'release' => $totalCurrency <= $department['balance'], 'percent' => $percent); $this->_helper->json($return); }
/** * * @param Zend_Db_Table_Row $campaign * @return boolean */ protected function _checkDepartment($campaign) { $dbCampaign = App_Model_DbTable_Factory::get('Campaign'); $mapperDepartment = new Admin_Model_Mapper_Department(); // Fetch the department $department = $mapperDepartment->detailDepartment($campaign->fk_id_department); // Check if the department has balance if ($department['balance'] <= 0) { $this->saveLog('DEPARTAMENTU: ' . $campaign->fk_id_department . ' NIA PULSA HOTU ONA ATU HARUKA KAMPANHA: ' . $campaign->id_campaign); $this->_mapperCampaign->saveLog('DEPARTAMENTU: ' . $campaign->fk_id_department . ' NIA PULSA HOTU ONA ATU HARUKA KAMPANHA', $campaign->id_campaign); // Set the campaign as initied $data = array('status' => Sms_Model_Mapper_Campaign::STATUS_INITIED); $where = array('id_campaign = ?' => $campaign->id_campaign); $dbCampaign->update($data, $where); $noteMapper = new Default_Model_Mapper_Note(); $noteModelMapper = new Default_Model_Mapper_NoteModel(); // Search the user who must receive notes when a department credit is over $noteTypeMapper = new Admin_Model_Mapper_NoteType(); $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::DEPARTMENT_CREDIT); $users[] = $department['fk_id_sysuser']; // save the warning to the user responsible of the department $dataNote = array('title' => 'DEPARTAMETNU-NIA PULSA HOTU ONA', 'level' => 0, 'message' => $noteModelMapper->getDepartmentCredit($department), 'users' => $users); $noteMapper->setData($dataNote)->saveNote(); return false; } return $department; }
/** * */ public function getFilters() { $filters = $this->_data; if (!empty($this->_data['fk_id_dec'])) { $dbDec = App_Model_DbTable_Factory::get('Dec'); $select = $dbDec->select()->from($dbDec, array('name_dec'))->where('id_dec IN(?)', $this->_data['fk_id_dec']); $rows = $dbDec->fetchAll($select); $filters['ceop'] = ''; foreach ($rows as $key => $row) { $filters['ceop'] .= $row->name_dec; if ($rows->count() != ++$key) { $filters['ceop'] .= ', '; } } } if (!empty($this->_data['fk_id_counselor'])) { $dbSysUser = App_Model_DbTable_Factory::get('SysUser'); $select = $dbSysUser->select()->from($dbSysUser, array('name'))->where('id_sysuser IN(?)', $this->_data['fk_id_counselor']); $rows = $dbSysUser->fetchAll($select); $filters['fk_id_counselor'] = ''; foreach ($rows as $key => $row) { $filters['fk_id_counselor'] .= $row->name; if ($rows->count() != ++$key) { $filters['fk_id_counselor'] .= ', '; } } } if (!empty($this->_data['fk_id_addcountry'])) { $mapperCountry = new Register_Model_Mapper_AddCountry(); $contry = $mapperCountry->fetchRow($this->_data['fk_id_addcountry']); $filters['country'] = $contry->country; } if (!empty($this->_data['fk_id_adddistrict'])) { $mapperDistrict = new Register_Model_Mapper_AddDistrict(); $district = $mapperDistrict->fetchRow($this->_data['fk_id_adddistrict']); $filters['district'] = $district->District; } if (!empty($this->_data['fk_id_fefpenterprise'])) { $mapperEnterprise = new Register_Model_Mapper_Enterprise(); $enterprise = $mapperEnterprise->fetchRow($this->_data['fk_id_fefpenterprise']); $filters['enterprise'] = $enterprise->enterprise_name; } if (!empty($this->_data['fk_id_fefpeduinstitution'])) { $mapperEducationInstititue = new Register_Model_Mapper_EducationInstitute(); $educationInstititute = $mapperEducationInstititue->fetchRow($this->_data['fk_id_fefpeduinstitution']); $filters['institute'] = $educationInstititute->institution; } if (!empty($this->_data['fk_id_profocupation'])) { $mapperOccupation = new Register_Model_Mapper_ProfOcupationTimor(); $occupation = $mapperOccupation->fetchRow($this->_data['fk_id_profocupation']); $filters['occupation'] = $occupation['acronym'] . ' ' . $occupation['ocupation_name_timor']; } if (!empty($this->_data['fk_id_scholarity_area'])) { $mapperScholarityArea = new Register_Model_Mapper_ScholarityArea(); $area = $mapperScholarityArea->fetchRow($this->_data['fk_id_scholarity_area']); $filters['area'] = $area['scholarity_area']; } if (!empty($this->_data['fk_id_pertypescholarity'])) { $mapperTypeScholarity = new Register_Model_Mapper_PerTypeScholarity(); $typeScholarity = $mapperTypeScholarity->fetchRow($this->_data['fk_id_pertypescholarity']); $filters['type_scholarity'] = $typeScholarity['type_scholarity']; } if (!empty($this->_data['fk_typeinstitution'])) { $mapperTypeInstitution = App_Model_DbTable_Factory::get('TypeInstitution'); $typeInstitution = $mapperTypeInstitution->fetchRow(array('id_typeinstitution = ?' => $this->_data['fk_typeinstitution'])); $filters['type_institution'] = $typeInstitution['type_institution']; } if (!empty($this->_data['fk_id_sectorindustry'])) { $mapperIsicClass = App_Model_DbTable_Factory::get('ISICClassTimor'); $sectorIndustry = $mapperIsicClass->fetchRow(array('id_isicclasstimor = ?' => $this->_data['fk_id_sectorindustry'])); $filters['sector_industry'] = $sectorIndustry['name_classtimor']; } if (!empty($this->_data['fk_fefptypeenterprite'])) { $mapperTypeEnterprise = App_Model_DbTable_Factory::get('FEFPTypeEnterprise'); $typeEnterprise = $mapperTypeEnterprise->fetchRow(array('id_fefptypeenterprise = ?' => $this->_data['fk_fefptypeenterprite'])); $filters['type_enterprise'] = $typeEnterprise['type_enterprise']; } if (!empty($this->_data['fk_id_perlevelscholarity'])) { $dbLevelScholarity = App_Model_DbTable_Factory::get('PerLevelScholarity'); $levelScholarity = $dbLevelScholarity->fetchRow(array('id_perlevelscholarity = ?' => $this->_data['fk_id_perlevelscholarity'])); $filters['level_scholarity'] = $levelScholarity['level_scholarity']; } if (!empty($this->_data['fk_id_perscholarity'])) { $mapperScholarity = new Register_Model_Mapper_PerScholarity(); $course = $mapperScholarity->fetchRow($this->_data['fk_id_perscholarity']); $filters['course'] = (empty($course['external_code']) ? '' : $course['external_code'] . ' - ') . $course['scholarity']; } if (!empty($this->_data['fk_id_sysuser'])) { $mapperSysUser = new Admin_Model_Mapper_SysUser(); $user = $mapperSysUser->fetchRow($this->_data['fk_id_sysuser']); $filters['user'] = $user['name'] . ' (' . $user['login'] . ')'; } if (!empty($this->_data['fk_id_department'])) { $mapperDepartment = new Admin_Model_Mapper_Department(); $department = $mapperDepartment->fetchRow($this->_data['fk_id_department']); $filters['department'] = $department['name']; } if (!empty($this->_data['fk_id_campaign_type'])) { $mapperCampaignType = new Sms_Model_Mapper_CampaignType(); $campaignType = $mapperCampaignType->fetchRow($this->_data['fk_id_campaign_type']); $filters['campaign_type'] = $campaignType['campaign_type']; } if (!empty($this->_data['status_campaign'])) { $view = Zend_Layout::getMvcInstance()->getView(); $optStatuses = $view->campaign()->getStatuses(); $filters['status_campaign'] = $optStatuses[$this->_data['status_campaign']]; } if (!empty($this->_data['fk_id_campaign'])) { $mapperCampaign = new Sms_Model_Mapper_Campaign(); $campaign = $mapperCampaign->fetchRow($this->_data['fk_id_campaign']); $filters['campaign_title'] = $campaign['campaign_title']; } if (!empty($this->_data['id_fefop_programs']) || !empty($this->_data['fk_id_fefop_programs'])) { $dbFEFOPPrograms = App_Model_DbTable_Factory::get('FEFOPPrograms'); if (!empty($this->_data['id_fefop_programs'])) { if (!is_array($this->_data['id_fefop_programs'])) { $row = $dbFEFOPPrograms->find($this->_data['id_fefop_programs'])->current(); $filters['fefop_program'] = $row->acronym . ' - ' . $row->description; } else { $select = $dbFEFOPPrograms->select()->from($dbFEFOPPrograms, array('description', 'acronym'))->where('id_fefop_programs IN(?)', $this->_data['id_fefop_programs']); $rows = $dbFEFOPPrograms->fetchAll($select); $filters['fefop_program'] = ''; foreach ($rows as $key => $row) { $filters['fefop_program'] .= $row->acronym . ' - ' . $row->description; if ($rows->count() != ++$key) { $filters['fefop_program'] .= ', '; } } } } else { if (!empty($this->_data['fk_id_fefop_programs'])) { $row = $dbFEFOPPrograms->find($this->_data['fk_id_fefop_programs'])->current(); $filters['fefop_program'] = $row->acronym . ' - ' . $row->description; } } } if (!empty($this->_data['id_fefop_modules']) || !empty($this->_data['fk_id_fefop_modules'])) { $dbFEFOPModules = App_Model_DbTable_Factory::get('FEFOPModules'); if (!empty($this->_data['id_fefop_modules'])) { if (!is_array($this->_data['id_fefop_modules'])) { $row = $dbFEFOPModules->find($this->_data['id_fefop_modules'])->current(); $filters['fefop_module'] = $row->acronym . ' - ' . $row->description; } else { $select = $dbFEFOPModules->select()->from($dbFEFOPModules, array('description', 'acronym'))->where('id_fefop_modules IN(?)', $this->_data['id_fefop_modules']); $rows = $dbFEFOPModules->fetchAll($select); $filters['fefop_module'] = ''; foreach ($rows as $key => $row) { $filters['fefop_module'] .= $row->acronym . ' - ' . $row->description; if ($rows->count() != ++$key) { $filters['fefop_module'] .= ', '; } } } } else { if (!empty($this->_data['fk_id_fefop_modules'])) { $row = $dbFEFOPModules->find($this->_data['fk_id_fefop_modules'])->current(); $filters['fefop_module'] = $row->acronym . ' - ' . $row->description; } } } if (!empty($this->_data['id_adddistrict'])) { $dbAddDistrict = App_Model_DbTable_Factory::get('AddDistrict'); if (is_array($this->_data['id_adddistrict'])) { $select = $dbAddDistrict->select()->from($dbAddDistrict, array('District'))->where('id_adddistrict IN(?)', $this->_data['id_adddistrict']); $rows = $dbAddDistrict->fetchAll($select); $filters['district'] = ''; foreach ($rows as $key => $row) { $filters['district'] .= $row->District; if ($rows->count() != ++$key) { $filters['district'] .= ', '; } } } else { $row = $dbAddDistrict->find($this->_data['id_adddistrict'])->current(); $filters['district'] = $row->District; } } if (!empty($this->_data['num_district'])) { $row = App_Model_DbTable_Factory::get('AddDistrict')->fetchRow(array('acronym = ?' => $this->_data['num_district'])); $filters['district'] = $row->District; } if (!empty($this->_data['id_scholarity_area'])) { $row = App_Model_DbTable_Factory::get('ScholarityArea')->find($this->_data['id_scholarity_area'])->current(); $filters['scholarity_area'] = (empty($row->acronym) ? '' : $row->acronym . ' - ') . $row->scholarity_area; } if (!empty($this->_data['id_profocupationtimor'])) { $row = App_Model_DbTable_Factory::get('PROFOcupationTimor')->find($this->_data['id_profocupationtimor'])->current(); $filters['ocupationtimor'] = $row->acronym . ' - ' . $row->ocupation_name_timor; } if (!empty($this->_data['id_fefpeduinstitution'])) { $row = App_Model_DbTable_Factory::get('FefpEduInstitution')->find($this->_data['id_fefpeduinstitution'])->current(); $filters['institution'] = $row->institution; } if (!empty($this->_data['fk_id_user_inserted'])) { $row = App_Model_DbTable_Factory::get('SysUser')->find($this->_data['fk_id_user_inserted'])->current(); $filters['user_inserted'] = $row->name; } if (!empty($this->_data['fk_id_user_removed'])) { $row = App_Model_DbTable_Factory::get('SysUser')->find($this->_data['fk_id_user_removed'])->current(); $filters['user_removed'] = $row->name; } if (array_key_exists('status', $this->_data) && is_numeric($this->_data['status'])) { $filters['status_description'] = $this->_data['status'] ? 'Loos' : 'Lae'; } if (!empty($this->_data['date_registration_ini'])) { $filters['date_registration_ini'] = $this->_data['date_registration_ini']; } if (!empty($this->_data['date_registration_fim'])) { $filters['date_registration_fim'] = $this->_data['date_registration_fim']; } if (!empty($this->_data['num_year'])) { $filters['num_year'] = $this->_data['num_year']; } if (!empty($this->_data['num_sequence'])) { $filters['num_sequence'] = $this->_data['num_sequence']; } if (array_key_exists('minimum_amount', $this->_data) && array_key_exists('maximum_amount', $this->_data)) { $min = new Zend_Currency('en_US'); $min->setValue($this->_data['minimum_amount']); $max = new Zend_Currency('en_US'); $max->setValue($this->_data['maximum_amount']); $filters['minmaxamount'] = $min . ' - ' . $max; } if (!empty($this->_data['id_fefop_status']) || !empty($this->_data['fk_id_fefop_status'])) { $dbFEFOPStatus = App_Model_DbTable_Factory::get('FEFOPStatus'); if (!empty($this->_data['id_fefop_status'])) { if (!is_array($this->_data['id_fefop_status'])) { $row = $dbFEFOPStatus->find($this->_data['id_fefop_status'])->current(); $filters['fefop_status'] = $row->status_description; } else { $select = $dbFEFOPStatus->select()->from($dbFEFOPStatus, array('status_description'))->where('id_fefop_status IN(?)', $this->_data['id_fefop_status']); $rows = $dbFEFOPStatus->fetchAll($select); $filters['fefop_status'] = ''; foreach ($rows as $key => $row) { $filters['fefop_status'] .= $row->status_description; if ($rows->count() != ++$key) { $filters['fefop_status'] .= ', '; } } } } else { $row = $dbFEFOPStatus->find($this->_data['fk_id_fefop_status'])->current(); $filters['fefop_status'] = $row->status_description; } } if (!empty($this->_data['id_budget_category_type'])) { $row = App_Model_DbTable_Factory::get('BudgetCategoryType')->find($this->_data['id_budget_category_type'])->current(); $filters['budget_category_type'] = $row->description; } if (!empty($this->_data['type_fefopfund'])) { if ('G' == $this->_data['type_fefopfund']) { $filters['description_type_fefopfund'] = 'Governo'; } else { $filters['description_type_fefopfund'] = 'Donor'; } } if (!empty($this->_data['id_beneficiary'])) { $mapper = new Fefop_Model_Mapper_Contract(); $adapter = App_Model_DbTable_Abstract::getDefaultAdapter(); $select = $adapter->select()->from(array('b' => new Zend_Db_Expr('(' . $mapper->getSelectBeneficiary() . ')')), array('name'))->where('b.id = ?', $this->_data['id_beneficiary']); $row = $adapter->fetchRow($select); $filters['beneficiary'] = $row['name']; } if (!empty($this->_data['type_beneficiary'])) { switch ($this->_data['type_beneficiary']) { case 'fk_id_staff': $type_beneficiary = 'Empreza Staff'; break; case 'fk_id_fefpenterprise': $type_beneficiary = 'Empreza'; break; case 'fk_id_fefpeduinstitution': $type_beneficiary = 'Inst Ensinu'; break; case 'fk_id_perdata': $type_beneficiary = 'Kliente'; break; default: $type_beneficiary = 'N/A'; } $filters['type_beneficiary'] = $type_beneficiary; } return $filters; }