mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
problema muestra genericos que no
This commit is contained in:
@ -145,7 +145,7 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "", $generico_id=-1)
|
||||
public function getResource(string $search = "", $generico_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -157,12 +157,12 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
t1.isActivo AS isActivo, t2.nombre AS papel_generico_id,
|
||||
t1.show_in_client AS show_in_client, t1.show_in_client_special AS show_in_client_special"
|
||||
);
|
||||
|
||||
|
||||
$builder->join("lg_papel_generico t2", "t1.papel_generico_id = t2.id", "left");
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
$builder->where("t1.isActivo", 1);
|
||||
if($generico_id>0){
|
||||
$builder->where("t1.papel_generico_id", $generico_id);
|
||||
if ($generico_id > 0) {
|
||||
$builder->where("t1.papel_generico_id", $generico_id);
|
||||
}
|
||||
|
||||
return empty($search)
|
||||
@ -182,29 +182,29 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"'".$maquina_id."'". " as maquina_id, t1.id AS papel_impresion_id, '0' as active"
|
||||
"'" . $maquina_id . "'" . " as maquina_id, t1.id AS papel_impresion_id, '0' as active"
|
||||
);
|
||||
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
$builder->where("t1.isActivo", 1);
|
||||
|
||||
$isFirst = true;
|
||||
$where_str = "";
|
||||
//Si hay tarifas...
|
||||
if (!empty($tarifas)){
|
||||
foreach ($tarifas as $tarifa){
|
||||
if (!empty($tarifas)) {
|
||||
foreach ($tarifas as $tarifa) {
|
||||
if (!$isFirst)
|
||||
$where_str .= ' OR ';
|
||||
else{
|
||||
else {
|
||||
$isFirst = false;
|
||||
}
|
||||
if ($tarifa->uso == 'cubierta')
|
||||
$where_str .= "`t1`.`cubierta`=1";
|
||||
else if ($tarifa->uso == 'sobrecubierta')
|
||||
$where_str .= "`t1`.`sobrecubierta`=1";
|
||||
else{
|
||||
else {
|
||||
if ($tarifa->tipo == 'negro' || $tarifa->tipo == 'negrohq')
|
||||
$where_str .= "`t1`.`bn`=1 ";
|
||||
$where_str .= "`t1`.`bn`=1 ";
|
||||
else
|
||||
$where_str .= "`t1`.`color`=1 ";
|
||||
}
|
||||
@ -212,11 +212,11 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
$builder->where($where_str);
|
||||
}
|
||||
// si no hay tarifas no hay que devolver nada
|
||||
else{
|
||||
else {
|
||||
// Se pone una condicion que no se puede dar
|
||||
$builder->where("t1.bn", 2);
|
||||
}
|
||||
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
@ -229,43 +229,45 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
*
|
||||
* @return [type]
|
||||
*/
|
||||
public function getIdPapelesImpresionForPresupuesto($papel_generico_id = null, $gramaje = null, $options=[]){
|
||||
public function getIdPapelesImpresionForPresupuesto($papel_generico_id = null, $gramaje = null, $options = [])
|
||||
{
|
||||
$bn = array_key_exists('bn', $options) ? $options['bn'] : null;
|
||||
$color = array_key_exists('color', $options)? $options['color'] : null;
|
||||
$cubierta = array_key_exists('cubierta', $options)? $options['cubierta'] : null;
|
||||
$sobrecubierta = array_key_exists('sobrecubierta', $options)? $options['sobrecubierta'] : null;
|
||||
$guardas = array_key_exists('guardas', $options)? $options['guardas'] : null;
|
||||
$rotativa = array_key_exists('rotativa', $options)? $options['rotativa'] : null;
|
||||
$color = array_key_exists('color', $options) ? $options['color'] : null;
|
||||
$cubierta = array_key_exists('cubierta', $options) ? $options['cubierta'] : null;
|
||||
$sobrecubierta = array_key_exists('sobrecubierta', $options) ? $options['sobrecubierta'] : null;
|
||||
$guardas = array_key_exists('guardas', $options) ? $options['guardas'] : null;
|
||||
$rotativa = array_key_exists('rotativa', $options) ? $options['rotativa'] : null;
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->distinct("t1.id")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.papel_generico_id AS papel_generico_id,
|
||||
t1.gramaje as gramaje, t1.espesor AS espesor, t1.precio_tonelada AS precio_tonelada, t1.rotativa AS rotativa");
|
||||
|
||||
t1.gramaje as gramaje, t1.espesor AS espesor, t1.precio_tonelada AS precio_tonelada, t1.rotativa AS rotativa"
|
||||
);
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
$builder->where("t1.isActivo", 1);
|
||||
|
||||
$builder->where("t1.papel_generico_id", $papel_generico_id);
|
||||
$builder->where("t1.gramaje", $gramaje);
|
||||
|
||||
if(!is_null($bn)){
|
||||
|
||||
if (!is_null($bn)) {
|
||||
$builder->where("t1.bn", $bn);
|
||||
}
|
||||
if(!is_null($color)){
|
||||
if (!is_null($color)) {
|
||||
$builder->where("t1.color", $color);
|
||||
}
|
||||
if(!is_null($cubierta)){
|
||||
if (!is_null($cubierta)) {
|
||||
$builder->where("t1.cubierta", $cubierta);
|
||||
}
|
||||
if(!is_null($sobrecubierta)){
|
||||
if (!is_null($sobrecubierta)) {
|
||||
$builder->where("t1.sobrecubierta", $sobrecubierta);
|
||||
}
|
||||
if(!is_null($guardas)){
|
||||
if (!is_null($guardas)) {
|
||||
$builder->where("t1.guardas", $guardas);
|
||||
}
|
||||
if(!is_null($rotativa)){
|
||||
if (!is_null($rotativa)) {
|
||||
$builder->where("t1.rotativa", $rotativa);
|
||||
}
|
||||
|
||||
@ -274,7 +276,8 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
|
||||
//tipo: negro, negrohq, color, colorhq
|
||||
//uso: interior, rotativa, cubierta, sobrecubierta
|
||||
public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso=""){
|
||||
public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->distinct("t1.id")
|
||||
@ -283,8 +286,9 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
|
||||
->join("lg_maquinas_tarifas_impresion t5", "t4.id = t5.maquina_id", "left")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS text");
|
||||
|
||||
"t1.id AS id, t1.nombre AS text"
|
||||
);
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
$builder->where("t1.isActivo", 1);
|
||||
$builder->where("t2.is_deleted", 0);
|
||||
@ -293,7 +297,7 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
$builder->where("t4.tipo", 'impresion');
|
||||
$builder->where("t5.is_deleted", 0);
|
||||
$builder->where("t5.tipo", $tipo);
|
||||
|
||||
|
||||
$builder->where("t2.id", $papel_generico);
|
||||
$builder->where("t1.gramaje", $gramaje);
|
||||
|
||||
@ -303,32 +307,35 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
$builder->where("t1.sobrecubierta", 1);
|
||||
else if ($uso == 'guardas')
|
||||
$builder->where("t1.guardas", 1);
|
||||
else{
|
||||
if($tipo == 'negro' || $tipo == 'negrohq')
|
||||
else {
|
||||
if ($tipo == 'negro' || $tipo == 'negrohq')
|
||||
$builder->where("t1.bn", 1);
|
||||
else if ($tipo == 'color' || $tipo == 'colorhq')
|
||||
$builder->where("t1.color", 1);
|
||||
}
|
||||
if($uso=='rotativa')
|
||||
if ($uso == 'rotativa')
|
||||
$builder->where("t1.rotativa", 1);
|
||||
else
|
||||
$builder->where("t1.rotativa", 0);
|
||||
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function getNombre($id){
|
||||
public function getNombre($id)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.nombre AS text");
|
||||
|
||||
"t1.nombre AS text"
|
||||
);
|
||||
|
||||
$builder->where("t1.id", $id);
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function getPapelGenericoCode($papel_id = 0){
|
||||
public function getPapelGenericoCode($papel_id = 0)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t2.code AS code")
|
||||
@ -337,12 +344,63 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.isActivo", 1)
|
||||
->where("t2.is_deleted", 0);
|
||||
|
||||
|
||||
$result = $builder->get()->getResultObject();
|
||||
if(count($result) > 0){
|
||||
if (count($result) > 0) {
|
||||
return $result[0]->code;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getGramajePresupuestoCliente($papel_generico_id = -1, $tipo = 'interior', $cubierta = 0, $papel_especial = 0)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.gramaje AS text"
|
||||
)
|
||||
->join("lg_papel_generico t2", "t2.id = t1.papel_generico_id", "inner")
|
||||
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
|
||||
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
|
||||
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
|
||||
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.isActivo", 1)
|
||||
->where("t1.use_in_client", 1)
|
||||
->where("t2.id", $papel_generico_id)
|
||||
->where("t2.show_in_client", 1)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t3.active", 1)
|
||||
->where("t4.is_deleted", 0)
|
||||
->where("t4.tipo", "impresion")
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $tipo)
|
||||
->distinct("t1.gramaje");
|
||||
|
||||
if($papel_especial){
|
||||
$builder->where('t2.show_in_client_special');
|
||||
}
|
||||
$uso_tarifa = 'interior';
|
||||
|
||||
if ($cubierta) {
|
||||
$uso_tarifa = 'cubierta';
|
||||
$builder->where("t1.cubierta", 1);
|
||||
} else {
|
||||
if ($tipo == 'negro' || $tipo == 'negrohq')
|
||||
$builder->where("t1.bn", 1);
|
||||
else if ($tipo == 'color' || $tipo == 'colorhq')
|
||||
$builder->where("t1.color", 1);
|
||||
}
|
||||
|
||||
$builder->where("t5.uso", $uso_tarifa);
|
||||
|
||||
|
||||
$values = $builder->orderBy("t1.gramaje", "asc")->get()->getResultObject();
|
||||
foreach ($values as $value) {
|
||||
$value->id = $value->text;
|
||||
}
|
||||
//$query=$this->db->getLastQuery();
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user