slice_sm_6_4.php <?php
// Pagina de metodos los slices
//
/******************** SLICE 6 *********************/
$enableHeader = false;
// 6
if(isset($save_update_profile_id))
{
$qr="UPDATE clients SET name='$profile_name' WHERE id=".$_SESSION['clients_id'];
mysql_query($qr) or die("<strong>Update client name<pre>".mysql_error()."</pre></strong>");
if($tipo_pago=='A'){ $pago=$pago_A; }else{ $pago=$pago_B;}
$qr="UPDATE client_profile SET represen='$profile_repre', position='$profile_position', phone='$profile_phone', email='$profile_email', address='".$profile_address.PARSER.$profile_addres s2."', description='".$profile_descrip."', tipo_pago='$tipo_pago', pago='$pago' WHERE id=".$save_update_profile_id;
mysql_query($qr) or die("<strong>Update client_profile<pre>".mysql_error()."</pre></strong>");
// se cambia de estado en el SLICE
//$_SESSION['client_estado']=1;
$_SESSION['mensaje']['txt'] = ADM_SUCCES_SAVED;
$_SESSION['mensaje']['status'] = true;
$enableHeader = true;
}
if(isset($delete_client_profile))
{
// QUERY DE BORRADO
//$qr="DELETE FROM client_profile WHERE id=".$delete_client_profile;
$qr="UPDATE client_profile SET estatus='B' WHERE id=".$delete_client_profile;
mysql_query($qr) or die("<strong>Delete client_profile<pre>".mysql_error()."</pre></strong>");
// Cambiamos de estatus otras relaciones importantes
// Reseteamos algunas variables
$_SESSION['client_estado']=1;
unset($_SESSION['clients_id']);
unset($_SESSION['client_profile_id']);
unset($_SESSION['proposal_id']);
$enableHeader = true;
}
//--------------------------------------------
// GUARDA POR PRIMERA VEZ UN PROPOSAL
if(isset($save_proposal_id))
{
$qr="INSERT into client_proposal (id, clients_id, slices_id, fecha, name, tipo, direccion, sdate, kdate, cost, textcost, stages, especifications, estatus) VALUES (NULL, ".$_SESSION['clients_id'].", ".$_SESSION['slices_id'].", '".date("Y-m-d")."', '$save_proposal_id', '$proposal_type', '".$proposal_addr1.PARSER.$proposal_addr2."', '".date("Y-m-d",strtotime($proposal_date1))."', '".date("Y-m-d",strtotime($proposal_date2))."', '$proposal_cost', '$proposal_textcost', '$proposal_stage', '$proposal_notes', 'E')";
mysql_query($qr) or die("<strong>Crea client_proposal<pre>".mysql_error()."</pre></strong>");
$qr="Select id from client_proposal where name='$save_proposal_id'";
$rs = mysql_query($qr) or die("<strong>Lee id nuevo proposal<pre>".mysql_error()."</pre></strong>");
$row = mysql_fetch_array($rs,MYSQL_ASSOC);
$_SESSION['proposal_id'] = $row['id']; // crea la variable de session que indica el proposal
$qr="UPDATE client_proposal SET name='$proposal_name' where name='$save_proposal_id'";
mysql_query($qr) or die("<strong>Cambia name del nuevo proposal<pre>".mysql_error()."</pre></strong>");
// se cambia de estado en el SLICE
$_SESSION['client_estado']=3;
$_SESSION['mensaje']['txt'] = ADM_SUCCES_SAVED;
$_SESSION['mensaje']['status'] = true;
$enableHeader = true;
}
// UPDATEA UN PROPOSAL
if(isset($update_proposal_id))
{
$qr="UPDATE client_proposal SET fecha='".date("Y-m-d")."', name='$proposal_name', tipo='$proposal_type', direccion='".$proposal_addr1.PARSER.$proposal_addr 2."', sdate='".date("Y-m-d",strtotime($proposal_date1))."', kdate='".date("Y-m-d",strtotime($proposal_date2))."', cost='$proposal_cost', textcost='$proposal_textcost', stages='$proposal_stage', especifications='$proposal_notes' WHERE id=".$update_proposal_id;
mysql_query($qr) or die("<strong>Update client_proposal<pre>".mysql_error()."</pre></strong>");
// se cambia de estado en el SLICE
$_SESSION['client_estado']=3;
$_SESSION['mensaje']['txt'] = ADM_SUCCES_SAVED;
$_SESSION['mensaje']['status'] = true;
$enableHeader = true;
}
// BORRA UN PROPOSAL
if(isset($delete_client_proposal))
{
// QUERY DE BORRADO
//$qr="DELETE FROM client_proposal WHERE id=".$delete_client_proposal;
$qr="UPDATE client_proposal SET estatus='B' WHERE id=".$delete_client_proposal;
mysql_query($qr) or die("<strong>Delete client_proposal<pre>".mysql_error()."</pre></strong>");
// Cambiamos de estatus otras relaciones importantes
// Reseteamos algunas variables
$_SESSION['client_estado']=1;
unset($_SESSION['proposal_id']);
$enableHeader = true;
}
//////////////////////////////////////////////
//para actualizar el invoice
if(($action_i=="update")and($_SESSION['invoice_id']!=''))
{
$invoice_date1 =date('Y-m-d',strtotime($invoice_date1));
$invoice_date2 =date('Y-m-d',strtotime($invoice_date2));
$quer="UPDATE client_invoice SET nro= '".$id_num."', fecha= '".date('Y-m-d')."', name= '".$invoice_name."', direccion= '".$invoice_addr1.PARSER.$invoice_addr2."', sdate= '".$invoice_date1."', kdate= '".$invoice_date2."', descri= '".$desc."', subtotal= ".$sub_total.", descuento= ".$dis.", newtotal= ".$nt.", tax= ".$tax1.", taxmount=".$tax2.", total= ".$tot.", estatus= 'E' WHERE id=".$_SESSION['invoice_id'];
mysql_query($quer) or die('ERROR AL UPDATE EL REGISTRO PRINCIPAL 1 '.mysql_error().$quer);
//update de los nombre de los items en pedidos
$qru="update item_pedidos set title='".$invoice_name."' where invoice_id=".$_SESSION['invoice_id']."";
mysql_query($qru)or die("ERROR FATAL UPDATE REGISTROS DE ITEMS (2.1)!!!".mysql_error().$qru);
$_SESSION['mensaje']['txt'] = ADM_SUCCES_SAVED;
$_SESSION['mensaje']['status'] = true;
$enableHeader = true;
}
//para grabar cuando pulso el boton rojo de invoice
if(($action_i=="save")and(!isset($_SESSION['invoice_id'])))
{
$q="select id from client_invoice WHERE name='".$id_pas."'";
$r=mysql_query($q)or die("ERRROR SLICE_SM_6.php".mysql_error());
if($ro=mysql_fetch_array($r))
{
$_SESSION['invoice_id']=$ro['id'];
}
$invoice_date1 =date('Y-m-d',strtotime($invoice_date1));
$invoice_date2 =date('Y-m-d',strtotime($invoice_date2));
$quer="UPDATE client_invoice SET nro= '".$id_num."', fecha= '".date('Y-m-d')."', name= '".$invoice_name."', direccion= '".$invoice_addr1.PARSER.$invoice_addr2."', sdate= '".$invoice_date1."', kdate= '".$invoice_date2."', descri= '".$desc."', subtotal= ".$sub_total.", descuento= ".$dis.", newtotal= ".$nt.", tax= ".$tax1.", taxmount=".$tax2.", total= ".$tot.", estatus= 'E' WHERE id=".$_SESSION['invoice_id'];
mysql_query($quer) or die('ERROR AL UPDATE EL REGISTRO PRINCIPAL 2 '.mysql_error().$quer);
//aqui se Actualiza los item con el nombre del proyecto
$qru="update item_pedidos set title='".$invoice_name."' where invoice_id=".$_SESSION['invoice_id']."";
mysql_query($qru)or die("ERROR FATAL UPDATE REGISTROS DE ITEMS (2.1)!!!".mysql_error().$qru);
unset($_SESSION['prop_invoice']);
$_SESSION['mensaje']['txt'] = ADM_SUCCES_SAVED;
$_SESSION['mensaje']['status'] = true;
$enableHeader = true;
}
// COPIAR UN INVOICE
if($action_i=="copy")
{
$query="select * from client_invoice where id = ".$_SESSION['invoice_id'];
$result=mysql_query($query);
if($row=mysql_fetch_array($result))
{ |