<?php
class DModelSettingProcessosVenda extends Model {

	public function getProcessosVendaItens($id_processo){
		$query = $this->db->query("SELECT  pci.*,
			oci.descricao AS status_inicial ,
			ocs.descricao AS status_sucesso,
			oce.descricao AS status_erro
			FROM oc_proccess_control_item  pci
			INNER JOIN  oc_order_situation oci on pci.order_situation_ini_id = oci.order_situation_id
			INNER JOIN  oc_order_situation ocs on pci.order_situation_suc_id = ocs.order_situation_id
			INNER JOIN  oc_order_situation oce on pci.order_situation_err_id = oce.order_situation_id
			WHERE proccess_control_id = " . (int)$id_processo . " order by ordem");
		return $query->rows;
	}

	public function getProcessosVendaItensStatus($id_processoItem){
		$this->load->type('tipofuturaserver');
		$query = $this->db->query("SELECT * 
		FROM oc_proccess_to_status 
		WHERE proccess_control_item_id  = " . (int)$id_processoItem . "
		ORDER BY tipo_status, tipo_status_prioridade");
		
		$data = false;
		if($query->rows){
			foreach ($query->rows as $key => $rows) {
				$data[$rows['tipo_status']]['name']     = Type_StatusProcVenda::getNickFromValue($rows['tipo_status']);
				$data[$rows['tipo_status']]['values'][] = $rows;				
			}
		}
		return $data;
	}


}
