Files
crewsportswear/app/Models/designer/DesignerModel.php

146 lines
3.8 KiB
PHP

<?php namespace App\Models\designer;
use Illuminate\Database\Eloquent\Model;
use DB;
class DesignerModel extends Model {
function selectTemplate($templateid){
$i = DB::table('templates')->where('HashTemplateCode', $templateid)
->get();
return $i;
}
function selectTemplatePaths($templateid){
$i = DB::table('template_paths')
->where('HashTemplateCode', $templateid)
->where('IsActive', 'TRUE')
->get();
return $i;
}
function selectTemplatePathsByTemplateCode($templateid){
$i = DB::table('template_paths')->where('TemplateCode', $templateid)
->where('IsActive', 'TRUE')
->get();
return $i;
}
function selectPatterns($patternId){
$i = DB::table('patterns')->where('PatternId', $patternId)
->get();
return $i;
}
function selectPatternColors($patternId){
$i = DB::table('pattern_colors')->where('PatternId', $patternId)
->get();
return $i;
}
function selectDefaultTemplateColor($templateCode){
$pdo = DB::connection()->getPdo();
$query = $pdo->prepare("SELECT NULL AS RGBIndex, RGBColor AS default_Color, DisplayName FROM template_body_colors WHERE TemplateCode = '$templateCode' UNION SELECT TrimNumber, RGBColor AS default_Color, DisplayName FROM template_trim_colors WHERE TemplateCode = '$templateCode'");
$query->execute();//$query->execute(array($bindings ));
// $row=$query->fetch(\PDO::FETCH_OBJ);
while($row=$query->fetch(\PDO::FETCH_OBJ)) {
if($row->RGBIndex == NULL){
$IndexName = "default_mainColor";
}else{
$IndexName = $row->RGBIndex;
}
$arr_default_mainColor[] = array(
$IndexName => $row->default_Color,
'h4_Trim_' . $IndexName => $row->DisplayName,
);
}
return $arr_default_mainColor;
}
function selectFontsByFontFamily($fontFamily){
$i = DB::table('fonts')->where('fontFamily', $fontFamily)
->get();
return $i;
}
function selectFonts(){
$i = DB::table('fonts')->get();
return $i;
}
function selectClipartCategories(){
$i = DB::table('clipart_categories')
->orderby('Ordering', 'ASC')
->get();
return $i;
}
function selectClipartByCategory($categortId){
$i = DB::table('cliparts')
->where('CategoryId', $categortId)
->get();
return $i;
}
function insertClientDesign($design_info){
$i = DB::table('client_designs')->insert($design_info);
return $i;
}
function selectClientDesign($designCode){
$i = DB::table('client_designs')
->where('DesignCode', $designCode)
->get();
return $i;
}
function selectProductURL($str){
$i = DB::table('teamstore_products')->select('ProductURL')
->get();
return $i;
}
function selectTeamStoreProductLastId(){
$i = DB::table('teamstore_products')->orderBy('Id', 'DESC')->first();
return $i;
}
function updateClientDesign($designName, $designCode){
$i = DB::table('client_designs')->where('DesignCode', $designCode)
->update(['DesignName' => $designName]);
return $i;
}
function selectPatternsByTable($table, $patternId){
$i = DB::table($table)->where('PatternId', $patternId)
->get();
return $i;
}
function getAvailableSizes($templateCode, $type){
$pdo = DB::connection()->getPdo();
$query = $pdo->prepare("SELECT ppl.Id, ppl.TemplateCode, ppl.Path, ppl.Type, ppl.Size, ppl.DateCreated, js.Size FROM print_pattern_list AS ppl LEFT JOIN sizes AS js ON js.Size = ppl.Size WHERE ppl.TemplateCode = '$templateCode' AND ppl.Type = '$type' ORDER BY js.Ordering ASC");
$query->execute();
while($row=$query->fetch(\PDO::FETCH_OBJ)) {
$arr_size[] = $row->Size;
}
return $arr_size;
}
function getDefaultPrice($size, $type){
$i = DB::table('default_prices')
->where('Size', $size)
->where('Type', $type)
->get();
return $i;
}
}