Uniformisation du code
This commit is contained in:
parent
cefa828419
commit
9e39bd7cdc
@ -162,9 +162,10 @@ if ($_POST['action'] == 'set_ref_client' && $user->rights->propale->creer)
|
||||
/*
|
||||
* Creation propale
|
||||
*/
|
||||
if ($_POST['action'] == 'add')
|
||||
if ($_POST['action'] == 'add' && $user->rights->propale->creer)
|
||||
{
|
||||
$propal = new Propal($db, $_POST['socidp']);
|
||||
$propal = new Propal($db);
|
||||
$propal->socidp=$_POST['socidp'];
|
||||
$propal->fetch_client();
|
||||
|
||||
$db->begin();
|
||||
@ -477,6 +478,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
|
||||
|
||||
// La description de la ligne est celle saisie ou
|
||||
// celle du produit si (non saisi + PRODUIT_CHANGE_PROD_DESC défini)
|
||||
// \todo Ne faut-il pas rendre $conf->global->PRODUIT_CHANGE_PROD_DESC toujours a on
|
||||
$desc=$_POST['np_desc'];
|
||||
if (! $desc && $conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
@ -1042,6 +1044,7 @@ if ($conf->expedition->enabled)
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a>';
|
||||
print ' - '.nl2br($objp->product);
|
||||
// \todo Ne faut-il pas rendre $conf->global->PRODUIT_CHANGE_PROD_DESC toujours a on
|
||||
if ($conf->global->FORM_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
print '<br>'.nl2br($objp->product_desc);
|
||||
@ -1177,7 +1180,7 @@ if ($conf->expedition->enabled)
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<textarea name="desc" cols="50" class="flat" rows="'.ROWS_2.'">'.$objp->description.'</textarea>';
|
||||
print '<textarea name="desc" cols="70" class="flat" rows="'.ROWS_2.'">'.$objp->description.'</textarea>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
@ -1373,7 +1376,7 @@ if ($conf->expedition->enabled)
|
||||
$var=true;
|
||||
|
||||
print '<tr '.$bc[$var].">\n";
|
||||
print '<td><textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea></td>';
|
||||
print '<td><textarea cols="70" name="np_desc" rows="'.ROWS_2.'"></textarea></td>';
|
||||
print '<td align="center">';
|
||||
if($societe->tva_assuj == "0")
|
||||
{
|
||||
@ -1413,7 +1416,7 @@ if ($conf->expedition->enabled)
|
||||
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
||||
}
|
||||
if (! $conf->use_ajax) print '<br>';
|
||||
print '<textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea>';
|
||||
print '<textarea cols="70" name="np_desc" rows="'.ROWS_2.'"></textarea>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right"><input type="text" size="2" name="qty" value="1"></td>';
|
||||
@ -1438,7 +1441,7 @@ if ($conf->expedition->enabled)
|
||||
{
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans('Note').'</td><td><textarea cols="60" rows="'.ROWS_3.'" wrap="soft" name="note">';
|
||||
print '<tr><td>'.$langs->trans('Note').'</td><td><textarea cols="70" rows="'.ROWS_3.'" wrap="soft" name="note">';
|
||||
print $propal->note;
|
||||
print '</textarea></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("CloseAs").'</td><td>';
|
||||
|
||||
@ -88,8 +88,11 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
||||
$datelivraison = @mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']);
|
||||
|
||||
$commande = new Commande($db);
|
||||
$commande->socidp=$_POST['socidp'];
|
||||
$commande->fetch_client();
|
||||
|
||||
$db->begin();
|
||||
|
||||
$commande->socidp = $_POST['socidp'];
|
||||
$commande->date_commande = $datecommande;
|
||||
$commande->note = $_POST['note'];
|
||||
$commande->source = $_POST['source_id'];
|
||||
@ -104,8 +107,6 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
||||
$commande->adresse_livraison_id = $_POST['adresse_livraison_id'];
|
||||
$commande->contactid = $_POST['contactidp'];
|
||||
|
||||
$commande->fetch_client();
|
||||
|
||||
$commande->add_product($_POST['idprod1'],$_POST['qty1'],$_POST['remise_percent1']);
|
||||
$commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']);
|
||||
$commande->add_product($_POST['idprod3'],$_POST['qty3'],$_POST['remise_percent3']);
|
||||
@ -117,13 +118,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
||||
|
||||
$commande_id = $commande->create($user);
|
||||
|
||||
if ($commande_id <= 0)
|
||||
{
|
||||
$_GET['action']='create';
|
||||
$_GET['socidp']=$_POST['socidp'];
|
||||
$mesg='<div class="error">'.$commande->error.'</div>';
|
||||
}
|
||||
else
|
||||
if ($commande_id > 0)
|
||||
{
|
||||
// Insertion contact par defaut si défini
|
||||
if ($_POST["contactidp"])
|
||||
@ -144,6 +139,20 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
||||
$_GET['id'] = $commande->id;
|
||||
$action = '';
|
||||
}
|
||||
|
||||
// Fin création facture, on l'affiche
|
||||
if ($commande_id > 0 && ! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$_GET["action"]='create';
|
||||
$_GET['socidp']=$_POST['socidp'];
|
||||
if (! $mesg) $mesg='<div class="error">'.$commande->error.'</div>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Positionne ref commande client
|
||||
@ -270,6 +279,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||
|
||||
// La description de la ligne est celle saisie ou
|
||||
// celle du produit si (non saisi + PRODUIT_CHANGE_PROD_DESC défini)
|
||||
// \todo Ne faut-il pas rendre $conf->global->PRODUIT_CHANGE_PROD_DESC toujours a on
|
||||
$desc=$_POST['np_desc'];
|
||||
if (! $desc && $conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
@ -677,7 +687,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
||||
// Reference client
|
||||
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
|
||||
print '<input type="text" name="ref_client" value=""></td>';
|
||||
print '<td rowspan="'.$nbrow.'" valign="top"><textarea name="note" wrap="soft" cols="50" rows="8"></textarea></td>';
|
||||
print '<td rowspan="'.$nbrow.'" valign="top"><textarea name="note" cols="70" rows="8"></textarea></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Client
|
||||
@ -1260,6 +1270,7 @@ else
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a> - '.nl2br($objp->product);
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.nl2br($objp->description):'';
|
||||
// \todo Ne faut-il pas rendre $conf->global->PRODUIT_CHANGE_PROD_DESC toujours a on
|
||||
if ($conf->global->FORM_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
print '<br>'.nl2br($objp->product_desc);
|
||||
@ -1369,7 +1380,7 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<textarea name="eldesc" class="flat" cols="50" rows="1">'.$objp->description.'</textarea>';
|
||||
print '<textarea name="eldesc" class="flat" cols="70" rows="1">'.$objp->description.'</textarea>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
@ -1551,7 +1562,7 @@ else
|
||||
|
||||
$var=true;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print ' <td><textarea cols="50" name="desc" rows="1"></textarea></td>';
|
||||
print ' <td><textarea cols="70" name="desc" rows="1"></textarea></td>';
|
||||
print '<td align="center">';
|
||||
if($soc->tva_assuj == "0")
|
||||
print '<input type="hidden" name="tva_tx" value="0">0';
|
||||
@ -1580,7 +1591,7 @@ else
|
||||
else
|
||||
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
||||
if (! $conf->use_ajax) print '<br>';
|
||||
print '<textarea cols="50" name="np_desc" rows="1"></textarea>';
|
||||
print '<textarea cols="70" name="np_desc" rows="1"></textarea>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right"><input type="text" size="2" name="qty" value="1"></td>';
|
||||
|
||||
@ -267,9 +267,14 @@ if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes'
|
||||
/*
|
||||
* Insertion facture
|
||||
*/
|
||||
if ($_POST['action'] == 'add')
|
||||
if ($_POST['action'] == 'add' && $user->rights->facture->creer)
|
||||
{
|
||||
$facture = new Facture($db);
|
||||
$facture->socidp=$_POST['socid'];
|
||||
$facture->fetch_client();
|
||||
|
||||
$db->begin();
|
||||
|
||||
if ($_POST['type'] == 1)
|
||||
{
|
||||
if ($_POST['fac_replacement'] > 0)
|
||||
@ -298,8 +303,8 @@ if ($_POST['action'] == 'add')
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=1;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("ReplaceInvoice")).'</div>';
|
||||
$_GET['action'] = 'create';
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,19 +364,7 @@ if ($_POST['action'] == 'add')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$facid = $facture->create($user);
|
||||
|
||||
if ($facid > 0)
|
||||
{
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"]='create';
|
||||
$mesg='<div class="error">'.$facture->error.'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -382,6 +375,7 @@ if ($_POST['action'] == 'add')
|
||||
{
|
||||
$facture->propalid = $_POST['propalid'];
|
||||
$facid = $facture->create($user);
|
||||
|
||||
if ($facid > 0)
|
||||
{
|
||||
$prop = New Propal($db);
|
||||
@ -408,12 +402,12 @@ if ($_POST['action'] == 'add')
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('UnknownError');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($facture->db,$facture->error);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,6 +418,7 @@ if ($_POST['action'] == 'add')
|
||||
{
|
||||
$facture->commandeid = $_POST['commandeid'];
|
||||
$facid = $facture->create($user);
|
||||
|
||||
if ($facid > 0)
|
||||
{
|
||||
$comm = New Commande($db);
|
||||
@ -451,12 +446,12 @@ if ($_POST['action'] == 'add')
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('UnknownError');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($facture->db,$facture->error);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,6 +462,7 @@ if ($_POST['action'] == 'add')
|
||||
{
|
||||
$facture->contratid = $_POST['contratid'];
|
||||
$facid = $facture->create($user);
|
||||
|
||||
if ($facid > 0)
|
||||
{
|
||||
$contrat = New Contrat($db);
|
||||
@ -501,25 +497,31 @@ if ($_POST['action'] == 'add')
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('UnknownError');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($facture->db,$facture->error);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Fin création facture, on l'affiche
|
||||
if ($facid > 0)
|
||||
if ($facid > 0 && ! $error)
|
||||
{
|
||||
$db->commit();
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid);
|
||||
exit;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$_GET["action"]='create';
|
||||
if (! $mesg) $mesg='<div class="error">'.$facture->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -581,6 +583,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
|
||||
|
||||
// La description de la ligne est celle saisie ou
|
||||
// celle du produit si (non saisi + PRODUIT_CHANGE_PROD_DESC défini)
|
||||
// \todo Ne faut-il pas rendre $conf->global->PRODUIT_CHANGE_PROD_DESC toujours a on
|
||||
$desc=$_POST['desc'];
|
||||
if (! $desc && $conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
@ -1909,9 +1912,10 @@ else
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):'';
|
||||
|
||||
// \todo Ne faut-il pas rendre $conf->global->PRODUIT_CHANGE_PROD_DESC toujours a on
|
||||
if ($conf->global->FORM_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
print '<br>'.nl2br(stripslashes($objp->product_desc));
|
||||
print '<br>'.nl2br($objp->product_desc);
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user