Example #1
0
 function enviafarmasis($numero)
 {
     $dbnumero = str_pad(intval($numero), 8, '0', STR_PAD_LEFT);
     $status = $this->datasis->dameval("SELECT status FROM ordc WHERE numero ={$dbnumero}");
     //if($status!='PE'){
     //	echo 'La orden ya fue procesada.';
     //	return;
     //}
     require_once APPPATH . '/controllers/farmacia/pedidos.php';
     $columnas = array('a.codigo', 'd.barras', 'b.descrip AS desca', 'a.cantidad AS pedir');
     $this->db->select($columnas);
     $this->db->from('itordc     AS a');
     $this->db->join('sinv       AS b', 'a.codigo=b.codigo');
     $this->db->join('farmaxasig AS d', 'a.codigo=d.abarras');
     $this->db->where('a.numero =', $dbnumero);
     $this->db->groupby('a.codigo');
     $this->db->distinct();
     $sql = $this->db->get();
     $_POST['apedir'] = array();
     if ($sql->num_rows() > 0) {
         foreach ($sql->result() as $row) {
             $_POST['apedir'][] = $row->barras . '#' . ceil($row->pedir);
         }
     } else {
         echo 'No existen productos';
     }
     $rt = Pedidos::_guardapedido();
     if ($rt['error'] == 0) {
         $this->db->simple_query("UPDATE ordc SET status='CE' WHERE numero ={$dbnumero}");
         echo $rt['msj'];
     } else {
         echo $rt['msj'] . ' ' . $rt['error'];
     }
 }