????
| Current Path : /home2/morganrand/backup.morganrand.com/centerpiece-designer/cp/application/models/ |
| Current File : /home2/morganrand/backup.morganrand.com/centerpiece-designer/cp/application/models/mdl_service.php |
<?php
class Mdl_service extends CI_Model
{
function getPompom()
{
$sql = "select p.name,p.code,p.color_code,p.pompom_id,p.color_image from pompom as p where p.is_del='n' and p.is_active='y' ORDER BY p.sort_on";
return $this->db->query($sql)->result_array();
}
function getPompomImages($pompom)
{
$retunArr=array();
foreach($pompom as $i=>$list) {
$sql = "select path,sort_on from images where category='POM' and category_id='".$list['pompom_id']."'ORDER BY sort_on";
$imagesRet=$this->db->query($sql)->result_array();
$images=array();
$pompom_number=array();
if(count($imagesRet)>0)
{
foreach ($imagesRet as $listin)
{
$pompom_number[]=$listin['sort_on'];
$path[$listin['sort_on']]=base_url().$listin['path'];
}
}
for($j=1;$j<=10;$j++)
{
if(in_array($j,$pompom_number))
{
$images[]=$path[$j];
}
else
{
$images[]='';
}
}
$retunArr[$i]['name']=$list['name'];
$retunArr[$i]['code']=$list['code'];
$retunArr[$i]['color_code']=$list['color_code'];
$retunArr[$i]['color_image']=($list['color_image']!='blank' && $list['color_image']!='')?base_url().$list['color_image']:'';
$retunArr[$i]['images']=$images;
}
return $retunArr;
}
function getTassels()
{
$sql = "select p.name,p.code,p.color_code,p.tassels_id,p.color_image from tassels as p where p.is_del='n' and p.is_active='y' ORDER BY p.sort_on";
return $this->db->query($sql)->result_array();
}
function getTasselsImages($tassels)
{
$retunArr=array();
foreach($tassels as $i=>$list) {
$sql = "select path,sort_on from images where category='TAS' and category_id='".$list['tassels_id']."'ORDER BY sort_on";
$imagesRet=$this->db->query($sql)->result_array();
$images=array();
$tassels_number=array();
if(count($imagesRet)>0)
{
foreach ($imagesRet as $listin)
{
$tassels_number[]=$listin['sort_on'];
$path[$listin['sort_on']]=base_url().$listin['path'];
}
}
for($j=1;$j<=6;$j++)
{
if(in_array($j,$tassels_number))
{
$images[]=$path[$j];
}
else
{
$images[]='';
}
}
$retunArr[$i]['name']=$list['name'];
$retunArr[$i]['code']=$list['code'];
$retunArr[$i]['color_code']=$list['color_code'];
$retunArr[$i]['color_image']=($list['color_image']!='blank' && $list['color_image']!='')?base_url().$list['color_image']:'';
$retunArr[$i]['images']=$images;
}
return $retunArr;
}
function getRibbons()
{
$sql = "select p.name,p.code,p.color_code,p.ribbons_id,p.color_image from ribbons as p where p.is_del='n' and p.is_active='y' ORDER BY p.sort_on";
return $this->db->query($sql)->result_array();
}
function getRibbonsImages($ribbons)
{
$retunArr=array();
foreach($ribbons as $i=>$list) {
$sql = "select path from images where category='RIB' and category_id='".$list['ribbons_id']."'ORDER BY sort_on";
$imagesRet=$this->db->query($sql)->result_array();
$images=array();
foreach($imagesRet as $j=>$listin) {
$images[]=base_url().$listin['path'];
}
$retunArr[$i]['name']=$list['name'];
$retunArr[$i]['code']=$list['code'];
$retunArr[$i]['color_code']=$list['color_code'];
$retunArr[$i]['color_image']=($list['color_image']!='blank' && $list['color_image']!='')?base_url().$list['color_image']:'';
$retunArr[$i]['images']=$images;
}
return $retunArr;
}
function getBases()
{
$sql = "select p.name,p.code,p.color_code,p.bases_id,p.color_image from bases as p where p.is_del='n' and p.is_active='y' ORDER BY p.sort_on";
return $this->db->query($sql)->result_array();
}
function getBasesImages($bases)
{
$retunArr=array();
foreach($bases as $i=>$list) {
$sql = "select path from images where category='BAS' and category_id='".$list['bases_id']."'ORDER BY sort_on";
$imagesRet=$this->db->query($sql)->result_array();
$images=array();
foreach($imagesRet as $j=>$listin) {
$images[]=base_url().$listin['path'];
}
$retunArr[$i]['name']=$list['name'];
$retunArr[$i]['code']=$list['code'];
$retunArr[$i]['color_code']=$list['color_code'];
$retunArr[$i]['color_image']=($list['color_image']!='blank' && $list['color_image']!='')?base_url().$list['color_image']:'';
$retunArr[$i]['images']=$images;
}
return $retunArr;
}
function getCandies()
{
$sql = "select p.name,p.code,p.color_code,p.candies_id,p.color_image from candies as p where p.is_del='n' and p.is_active='y' ORDER BY p.sort_on";
return $this->db->query($sql)->result_array();
}
function getCandiesImages($candies)
{
$retunArr=array();
foreach($candies as $i=>$list) {
$sql = "select path from images where category='CAN' and category_id='".$list['candies_id']."'ORDER BY sort_on";
$imagesRet=$this->db->query($sql)->result_array();
$images=array();
foreach($imagesRet as $j=>$listin) {
$images[]=base_url().$listin['path'];
}
$retunArr[$i]['name']=$list['name'];
$retunArr[$i]['code']=$list['code'];
$retunArr[$i]['color_code']=$list['color_code'];
$retunArr[$i]['color_image']=($list['color_image']!='blank' && $list['color_image']!='')?base_url().$list['color_image']:'';
$retunArr[$i]['images']=$images;
}
return $retunArr;
}
function getCombinecandies()
{
$sql = "select cc.*,concat((select name from candies as c where c.code=cc.code1 and c.is_del='n'),' ',(select name from candies as c where c.code=cc.code2 and c.is_del='n')) as name , (select color_code from candies as c where c.code=cc.code1 and c.is_del='n') as color_code1, (select color_code from candies as c where c.code=cc.code2 and c.is_del='n') as color_code2 from combinecandies as cc where cc.is_del='n' ORDER BY cc.sort_on";
return $this->db->query($sql)->result_array();
}
function getCombinecandiesImages($combinecandies)
{
$retunArr=array();
foreach($combinecandies as $i=>$list) {
$sql = "select path from images where category='CCAN' and category_id='".$list['combinecandies_id']."'ORDER BY sort_on";
$imagesRet=$this->db->query($sql)->result_array();
$images=array();
foreach($imagesRet as $j=>$listin) {
$images[]=base_url().$listin['path'];
}
$retunArr[$i]['name']=$list['name'];
$retunArr[$i]['code1']=$list['code1'];
$retunArr[$i]['code2']=$list['code2'];
$retunArr[$i]['color_code1']=$list['color_code1'];
$retunArr[$i]['color_code2']=$list['color_code2'];
$retunArr[$i]['images']=$images;
}
return $retunArr;
}
function getSetting()
{
$sql = "select p.name,p.setting_value from setting as p where p.is_del='n'";
return $this->db->query($sql)->result_array();
}
}