222 lines
7.6 KiB
PHP
222 lines
7.6 KiB
PHP
<?php
|
|
|
|
class Combo_model extends CI_Model {
|
|
|
|
var $optCons = '';
|
|
var $currentStyle = 'form-control select';
|
|
var $readOnlyMode = false;
|
|
var $defaultComboMessage = 'Select...';
|
|
var $showDefaultSelect = true;
|
|
|
|
function __construct() {
|
|
|
|
}
|
|
|
|
public function marketTimeline($option_name, $curVal)
|
|
{
|
|
$marketArray = [];
|
|
for ($i = 2; $i <= 6; $i = $i + 1) {
|
|
$marketArray[] = [$i,$i,'Days'];
|
|
}
|
|
$ic=0;
|
|
for ($i = 7; $i <= 21; $i = $i + 7) {
|
|
$ic++;
|
|
$marketArray[] = [$i,$ic,'Week(s)'];
|
|
}
|
|
$ic=0;
|
|
for ($i = 30; $i <= 90; $i = $i + 30) {
|
|
$ic++;
|
|
$marketArray[] = [$i,$ic,'Month(s)'];
|
|
}
|
|
|
|
$cmbstr ="<option value='0'>Select Market Timeline for this job</option>";
|
|
foreach ($marketArray as $item) {
|
|
|
|
$i = $item[0];
|
|
$ii = $item[1];
|
|
$description =$item[2];
|
|
$selV = '';
|
|
if ($curVal == $i) {
|
|
$selV = " selected ";
|
|
}
|
|
$cmbstr .= "<option value='".$i."' ".$selV.">".$ii." ".$description."</option>";
|
|
}
|
|
return $this->comboFrame($option_name, $cmbstr);
|
|
|
|
}
|
|
|
|
|
|
public function getJobPriceCombo($option_name,$description, $curVal){
|
|
|
|
$this->defaultComboMessage ='Select Price...';
|
|
$cmbstr ="<option value='0'>". $this->defaultComboMessage ."</option>";
|
|
for ($i = 2000; $i <= 10000; $i = $i + 1000) {
|
|
// $amountArray[] = [$i,$i,'Naira'];
|
|
$selV = '';
|
|
if ($curVal == $i) {
|
|
$selV = " selected ";
|
|
}
|
|
$cmbstr .= "<option value='".$i."' ".$selV.">".$i." ".$description."</option>";
|
|
}
|
|
return $this->comboFrame($option_name, $cmbstr);
|
|
}
|
|
public function getJobPostDuration($option_name, $duration)
|
|
{
|
|
$this->defaultComboMessage ='Select duration of post';
|
|
$cmbstr ="";
|
|
for ($ii = 2; $ii <= 10; $ii++) {
|
|
|
|
$cmbstr .= "<option value='$ii'>$ii day(s)</option>";
|
|
}
|
|
|
|
for ($ii = 2; $ii <= 5; $ii++) {
|
|
$days_c = $ii*7;
|
|
$cmbstr .= "<option value='$days_c'>$ii Weeks</option>";
|
|
}
|
|
return $this->comboFrame($option_name, $cmbstr);
|
|
}
|
|
public function getUserJobGroupCombo($option_name, $member_id, $curVal) {
|
|
|
|
// $sql = "SELECT id,group_name FROM members_job_group WHERE member_id = $member_id AND status = 1 ORDER BY group_name ASC ";
|
|
$sql = "SELECT m.id,m.group_name, m.group_name||' ['||count(g.group_id)||' members]' AS member_group_count "
|
|
. "FROM members_job_group m "
|
|
. "LEFT JOIN members_job_groupmember g ON g.group_id = m.id "
|
|
. "WHERE m.member_id = $member_id "
|
|
. "AND m.status = 1 GROUP BY m.id,m.group_name ORDER BY m.group_name ASC";
|
|
|
|
$q = $this->db->query($sql);
|
|
$option_value = $this->optionValueObject($q->result(), "id", "member_group_count", $curVal);
|
|
return $this->comboFrame($option_name, $option_value);
|
|
}
|
|
|
|
public function getUserRecipientCombo($option_name, $member_id, $curVal) {
|
|
|
|
$sql = "SELECT b.id,b.firstname||' '||b.lastname||' '||b.account_no||' '||k.name AS recipient "
|
|
. "FROM sendmoney_recipient b "
|
|
. "LEFT JOIN bank_entity_codes k ON k.code=b.bank_code "
|
|
. "WHERE b.member_id = $member_id AND b.status=1";
|
|
|
|
$q = $this->db->query($sql);
|
|
$option_value = $this->optionValueObject($q->result(), "id", "recipient", $curVal);
|
|
return $this->comboFrame($option_name, $option_value);
|
|
}
|
|
|
|
public function getAccountTypeCombo($option_name, $curVal) {
|
|
$q = $this
|
|
->db
|
|
->where('status', 1)
|
|
->order_by('type_name', 'ASC')
|
|
->get('account_types');
|
|
|
|
$option_value = $this->optionValueObject($q->result(), "type_value", "type_name", $curVal);
|
|
|
|
return $this->comboFrame($option_name, $option_value);
|
|
}
|
|
|
|
public function getGeneralSkillCombo($option_name, $curVal) {
|
|
$this->showDefaultSelect = false;
|
|
$q = $this
|
|
->db
|
|
->where('status', 1)
|
|
->order_by('lorder', 'DESC')
|
|
->get('skill_category');
|
|
$option_value = $this->optionValueObject($q->result(), "id", "category", $curVal);
|
|
|
|
return $this->comboFrame($option_name, $option_value);
|
|
}
|
|
|
|
public function getUserNewSkillCombo($option_name, $curVal, $category_id, $member_id) {
|
|
$q = $this
|
|
->db
|
|
->where('status', 1)
|
|
->where('category_id', $category_id)
|
|
->order_by('lorder', 'DESC')
|
|
->get('skill_types');
|
|
$option_value = $this->optionValueObject($q->result(), "id", "skill", $curVal);
|
|
|
|
return $this->comboFrame($option_name, $option_value);
|
|
}
|
|
|
|
public function setReadOnly($bl) {
|
|
$this->readOnlyMode = $bl;
|
|
}
|
|
|
|
public function getCountryCombo($option_name, $curVal) {
|
|
$q = $this
|
|
->db
|
|
->where('status', 1)
|
|
->order_by('country', 'ASC')
|
|
->get('country');
|
|
|
|
$option_value = $this->optionValueObject($q->result(), "code", "country", $curVal);
|
|
|
|
return $this->comboFrame($option_name, $option_value);
|
|
}
|
|
|
|
public function getCountryJobCombo($option_name, $curVal) {
|
|
$q = $this
|
|
->db
|
|
->where('status', 1)
|
|
->where('jobs is NOT NULL', NULL, FALSE)
|
|
->order_by('country', 'ASC')
|
|
->get('country');
|
|
|
|
$option_value = $this->optionValueObject($q->result(), "code", "country", $curVal);
|
|
|
|
return $this->comboFrame($option_name, $option_value);
|
|
}
|
|
|
|
public function getBankCombo($option_name, $curVal) {
|
|
/*
|
|
wrenchboard=> Select code,name from bank_entity_codes WHERE country ='NG' ORDER BY name ASC;
|
|
code | name
|
|
------+------------------------------------------------
|
|
044 | Access Bank
|
|
014 | Afri Bank
|
|
023 | Citi Bank
|
|
063 | Diamond Bank
|
|
050 | Ecobank
|
|
040 | Equitorial Trust Bank
|
|
*/
|
|
|
|
$q = $this
|
|
->db
|
|
->where('status', 1)
|
|
->order_by('name', 'ASC')
|
|
->get('bank_entity_codes');
|
|
|
|
$option_value = $this->optionValueObject($q->result(), "code", "name", $curVal);
|
|
|
|
return $this->comboFrame($option_name, $option_value);
|
|
}
|
|
|
|
|
|
private function optionValueObject($sdStd, $val, $valname, $curVal) {
|
|
$this->optCons = '';
|
|
if ($this->showDefaultSelect == true) {
|
|
$this->optCons .= "<option value=''>" . $this->defaultComboMessage . "</option>";
|
|
}
|
|
|
|
|
|
foreach ($sdStd as $row) {
|
|
$selV = '';
|
|
if ($curVal == $row->$val) {
|
|
$selV = " selected ";
|
|
}
|
|
$this->optCons .= "<option value='" . $row->$val . "' " . $selV . ">" . $row->$valname . "</option>";
|
|
}
|
|
return $this->optCons;
|
|
}
|
|
|
|
private function comboFrame($option_name, $option_value) {
|
|
$addReaOnly = "";
|
|
if ($this->readOnlyMode == true) {
|
|
$addReaOnly = " disabled ";
|
|
}
|
|
//form-select form-select-solid form-select-lg
|
|
$style_line = "form-select form-select-solid form-select-lg";
|
|
return $cmb = "<select $style_line data-placeholder='".$this->defaultComboMessage."' class='" . $this->currentStyle . "' name='$option_name' $addReaOnly >$option_value</select>";
|
|
}
|
|
|
|
}
|