Ver Mensaje Individual
  #16 (permalink)  
Antiguo 23/09/2005, 17:53
Avatar de davidangel
davidangel
 
Fecha de Ingreso: abril-2005
Mensajes: 124
Antigüedad: 19 años, 7 meses
Puntos: 0
slice_sm6_dinvoice_67.php

<?php
require_once("valida_apertura_pagina.php");
require_once("db_access.php");
$manda_data=false;
////////////////////producto o servicio///////
function busca_produc($nnn)
{
$query="select * from items where id=".$nnn." and tipo='P' ";
$result=mysql_query($query);
if(mysql_num_rows($result)!=0)//2 o 1 0 3
{
$produc = true;
}else{
$produc = false;
}
return $produc;
}
//en caso de q sea desde el boton negro
function descri_pago($m,&$n,&$w)
{
if($m==1)
{
$title= MSG_6_85;
$money= ($w * 25) / 100;
}else if($m==2){
$title= MSG_6_86;
$money= ($w * 25) / 100;
}else if($m==3) {
$title= MSG_6_87;
$money= ($w * 50) / 100;
}
$w=$money ;
$n=$title;
}
//ELIMINAR ITEMS
if($elimina_i!=0)
{
$que="select items_id from client_detalle_invoice where id=".$elimina_i."";
$res=mysql_query($que);
$ro=mysql_fetch_array($res);
if($ro['items_id']!=0)
{
if(busca_produc($ro['items_id']))
{
// QUERY DE BORRADO
//$qru="delete from item_pedidos where items_id=".$ro['items_id']." and invoice_id=".$_SESSION['invoice_id'];
$qru="UPDATE item_pedidos SET estatus='B' WHERE items_id=".$ro['items_id']." AND invoice_id=".$_SESSION['invoice_id'];
mysql_query($qru)or die("ERROR FATAL BORRAR REGISTROS DE ITEMS PEDIDOS (1)!!!".mysql_error().$qru);
}
}
// QUERY DE BORRADO
//$eli_i="DELETE from client_detalle_invoice where id=".$elimina_i."";
$eli_i="UPDATE client_detalle_invoice SET estatus='B' WHERE id=".$elimina_i;
mysql_query($eli_i);
$ej=true;
}
//////////////////////////////////////////////////////////////////////////////////////////
if($_SESSION['prop_invoice']!="" and $nadd==0 or $nadd=="" and $_SESSION['prop_invoice']!="")
{
$var_S = explode(PARSER,$_SESSION['prop_invoice']);
$id_1_pro = $var_S[0];
$id_2_num = $var_S[1];
$consul="select * from client_prop_inv where client_proposal_id=".$id_1_pro." and numero=".$id_2_num."";
$resulta=mysql_query($consul) or die("ERROR EN PROPOSAL_VAR ".mysql_error().$consul);
if(mysql_num_rows($resulta)==0)
{
$consulta="select * from client_proposal where id =".$id_1_pro." and estatus ='E'";
$resultado=mysql_query($consulta) or die("ERROR AL SELECCIONAR CLIENT_PROPOSAL".mysql_error().$consulta);
$filas=mysql_fetch_array($resultado);
$exp="";
descri_pago($id_2_num,$exp,$filas['cost']);
$s_invoice="add";
$nadd = 1;
$dir = explode(PARSER,$filas['direccion']);
$filas["sdate"] = date("m/d/y",strtotime($filas["sdate"]));
$filas["kdate"] = date("m/d/y",strtotime($filas["kdate"]));
$manda_data=true;
$relation="crea";
}
}
//
$id_pas=false;
$id_pas1=false;
////////////////////////////////////////////////////////////////////////////////////////////////
function tipo_i($inv)
{
if($inv=="P")
{
$a= MSG_6_88;
}else if($inv=="S"){
$a= MSG_6_89;
}
return $a;
}
///////////////////////////////////////////////////
function select_data($y,$x,$b,$c)
{
if($x==1){

$query="select * from items where id=".$y;
$result=mysql_query($query)or die("ERROR EN LA CONSULTA".mysql_error().$query);
while($row=mysql_fetch_array($result))
{
$b=$row['nombre'].tipo_i($row['tipo']);
if($b=='')
{
$b="ID - ".$row['nro_unico'];
}
}
}
else if($x==2)
{
$query="select * from item_profile where items_id=".$y." and slices_id=".$_SESSION['slices_id'];
$result=mysql_query($query)or die("ERROR EN LA CONSULTA".mysql_error().$query);
while($row=mysql_fetch_array($result))
{
if($row['tipo_cobro']=='F')
{
$b=number_format($row['fee'],2,".","");
}else if($row['tipo_cobro']=='H'){
$b=number_format($row['cost'],2,".","");
}else if(($row['tipo_cobro']=='J') or empty($row['tipo_cobro'])) {
$b=number_format($row['retail'],2,".","");
}
//************************************************** ****************************************//
if($b=='')
{
$b="0";
}
}
}
return $b;
}

////////////////////////////////////////////////////////////////////////////////////////////////
function nuevo_row_add($a=1,$A=array(),&$b,&$c,$max,$esc,$w w,$caso3,$caso3_1) {
$numg=$a;
$lista="\r\n";

for($i=0;$i<count($A);$i++)
{
// en caso de q sea un item
if($esc!=""){
if($esc!="all" and $i==($max-1)){$A[$i][4]=select_data($esc,1,'','');}
if($esc!="all" and $i==($max-1)){$A[$i][2]=select_data($esc,2,'','');}
if($esc!="all" and $i==($max-1)){$A[$i][1]="1";}
if($esc!="all" and $i==($max-1)){$A[$i][3]=number_format($A[$i][1] * $A[$i][2],2,".","");}
if($esc!="all" and $i==($max-1)){$A[$i][5]=$esc;}
}
//en caso desde proposal
if($esc=="" and $numg==1){
if($esc=="" and $i==($max-1)){$A[$i][4]=$caso3;}
if($esc=="" and $i==($max-1)){$A[$i][2]=number_format($caso3_1,2,".","");}
if($esc=="" and $i==($max-1)){$A[$i][1]="1";}
if($esc=="" and $i==($max-1)){$A[$i][3]=number_format($A[$i][1] * $A[$i][2],2,".","");}
if($esc=="" and $i==($max-1)){$A[$i][5]=$esc;}
}
//en caso de q sea other
$lista.="<table width=\"392\" cellpadding=\"0\" cellspacing=\"0\" border=\"1\" bgcolor=\"#ffffff\">\r\n";
$lista.="<tr bgcolor=\"#eaeaea\">\r\n";
$lista.=" <input type=\"Hidden\" id=\"id_unic".$numg."\" value=\"\"><input type=\"Hidden\" name=\"idAP".$i."\"><input type=\"Hidden\" name=\"x".$i."[5]\" value=\"".$A[$i][5]."\" id=\"id_i".$numg."\">\r\n";
$lista.=" <td width=\"250\" valign=\"top\"><table cellpadding=\"0\" cellpadding=\"0\" border=\"0\" width=\"15\" height=\"15\"><tr><td valign=\"baseline\"><img src=\"images/delete_icon.gif\" alt=\"[ Delete ]\" width=\"15\" height=\"15\" border=\"0\" style=\"cursor:pointer;\" onclick=\"borra_html(".$numg.",".$i.");\"></td><td><input type=\"Text\" name=\"x".$i."[4]\" value=\"".$A[$i][4]."\" id=\"descript".$numg."\" class=\"n10\" style=\"width:226px;\"></td></tr></table></td>\r\n";
$lista.=" <td width=\"35\"><input name=\"x".$i."[1]\" id=\"q".$numg."\" type=\"Text\" class=\"n10\" style=\"width:35px;\" value=\"".$A[$i][1]."\" onkeyup=\"subtotal()\" onkeypress=\"subtotal()\"></td>\r\n";
$lista.=" <td width=\"50\"><input name=\"x".$i."[2]\" id=\"cost".$numg."\" type=\"Text\" class=\"n10\" style=\"width:50px;\" value=\"".$A[$i][2]."\" onkeyup=\"subtotal()\" onkeypress=\"subtotal()\"></td>\r\n";
$lista.=" <td width=\"50\"><input name=\"x".$i."[3]\" id=\"s_total".$numg."\" readonly=\"true\" class=\"n10\" value=\"".$A[$i][3]."\" style=\"width:50px;\"></td>\r\n";
$lista.="</tr>\r\n";
$lista.="</table>\r\n";
$numg++;
}
$b = $lista;
$c = $numg;
}

/////////////////////////////////////////////////////////////////////////////////////////////////
/////funcion para leer la data
function write_detalle_i(&$x,&$y,&$z,&$rw) {
$lista="\r\n";
$numg=1;
if($_SESSION['invoice_id']!="")
{
$qr = "SELECT * FROM client_detalle_invoice WHERE client_invoice_id = ".$_SESSION['invoice_id'];
$rs = mysql_query($qr) or die("<strong><pre>writePlanStep: ".mysql_error().$qr."</pre></strong>");
$num = mysql_num_rows($rs);
if(mysql_num_rows($rs)!=0) {
while($row=mysql_fetch_array($rs)) {
// en caso de q sea other
$row['costo']=number_format($row['costo'],2,".","");
$row['total']=number_format($row['costo'] * $row['cantidad'],2,".","");
$lista.="<table width=\"392\" cellpadding=\"0\" cellspacing=\"0\" border=\"1\" bgcolor=\"#ffffff\">\r\n";
$lista.="<tr bgcolor=\"#eaeaea\">\r\n";
$lista.=" <input type=\"Hidden\" id=\"id_unic".$numg."\" value=\"".$row['id']."\"><input type=\"Hidden\" value=\"".$row['items_id']."\" id=\"id_i".$numg."\">\r\n";
$lista.=" <td width=\"250\" valign=\"top\"><table cellpadding=\"0\" cellpadding=\"0\" border=\"0\" width=\"15\" height=\"15\"><tr><td valign=\"baseline\"><img src=\"images/delete_icon.gif\" alt=\"[ Delete ]\" width=\"15\" height=\"15\" border=\"0\" style=\"cursor:pointer;\" onclick=\"elimina_item(".$row['id'].");\"></td><td><input type=\"Text\" value=\"".$row['descri']."\" id=\"descript".$numg."\" class=\"n10\" style=\"width:226px;\"></td></tr></table></td>\r\n";
$lista.=" <td width=\"35\"><input id=\"q".$numg."\" type=\"Text\" class=\"n10\" style=\"width:35px;\" value=\"".$row['cantidad']."\" onkeyup=\"subtotal()\" onkeypress=\"subtotal()\"></td>\r\n";
$lista.=" <td width=\"50\"><input id=\"cost".$numg."\" type=\"Text\" class=\"n10\" style=\"width:50px;\" value=\"".$row['costo']."\" onkeyup=\"subtotal()\" onkeypress=\"subtotal()\"></td>\r\n";
$lista.=" <td width=\"50\"><input readonly=\"true\" id=\"s_total".$numg."\" class=\"n10\" value=\"".$row['total']."\" style=\"width:50px;\"></td>\r\n";
$lista.="</tr>\r\n";
$lista.="</table>\r\n";
$numg++;
}
}
}
$x = $lista;
$y = $numg;
$z = $num;
$rw=$numg;
}/////////////////////////////////////////////////////////////////////////////////////////////////
$items_cod="";
write_detalle_i($WPtitle,$numg,$num_1,$items_cod);
/***********************/////////////////////////////////////////////////////////////////////////

if($s_invoice=="add")
{
for($k=0;$k<$nadd;$k++)
{
for($l=1;$l<6;$l++)
{
$trow = "x".$k."[".$l."]";
$ADD[$k][$l] = $$trow;
}
}
nuevo_row_add($numg,$ADD,$newR,$numg,$nadd,$id_v,$ num_1,$exp,$filas['cost']);
$ej = true;
}