Fix: problem if hidedesc id used

Fix: uniformize code
This commit is contained in:
Regis Houssin 2011-04-18 15:06:23 +00:00
parent bb209e3c34
commit 15fe7b5bd8
11 changed files with 214 additions and 214 deletions

View File

@ -50,6 +50,7 @@ $ref=GETPOST('ref');
$socid=GETPOST('socid');
$action=GETPOST('action');
$confirm=GETPOST('confirm');
$lineid=GETPOST('lineid');
$sall=GETPOST("sall");
$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
@ -1429,7 +1430,7 @@ if ($id > 0 || ! empty($ref))
print '<table id="tablelines" class="noborder" width="100%">';
// Show object lines
if (! empty($object->lines)) $object->printObjectLines(GETPOST('action'),$mysoc,$soc,GETPOST('lineid'));
if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid);
//print '<table id="tablelines" class="noborder" width="100%">';
@ -1438,7 +1439,7 @@ if ($id > 0 || ! empty($ref))
*/
if ($object->statut == 0 && $user->rights->propale->creer)
{
if ($_GET['action'] != 'editline')
if ($action != 'editline')
{
$var=true;
@ -1471,7 +1472,7 @@ if ($id > 0 || ! empty($ref))
print '</div>';
print "\n";
if ($_GET['action'] == 'statut')
if ($action == 'statut')
{
/*
* Formulaire cloture (signe ou non)
@ -1504,11 +1505,11 @@ if ($id > 0 || ! empty($ref))
/*
* Boutons Actions
*/
if ($_GET['action'] != 'presend')
if ($action != 'presend')
{
print '<div class="tabsAction">';
if ($_GET['action'] != 'statut' && $_GET['action'] <> 'editline')
if ($action != 'statut' && $action <> 'editline')
{
// Validate
if ($object->statut == 0 && $user->rights->propale->valider)
@ -1584,7 +1585,7 @@ if ($id > 0 || ! empty($ref))
print "<br>\n";
}
if ($_GET['action'] != 'presend')
if ($action != 'presend')
{
print '<table width="100%"><tr><td width="50%" valign="top">';
print '<a name="builddoc"></a>'; // ancre
@ -1639,7 +1640,7 @@ if ($id > 0 || ! empty($ref))
* Action presend
*
*/
if ($_GET['action'] == 'presend')
if ($action == 'presend')
{
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->propale->dir_output . '/' . $ref . '/' . $ref . '.pdf';

View File

@ -51,13 +51,16 @@ $langs->load('propal');
$langs->load('deliveries');
$langs->load('products');
$comid = GETPOST("id");
if (empty($comid)) $comid=GETPOST("orderid");
$id=(GETPOST("id")?GETPOST("id"):GETPOST("orderid"));
$ref=GETPOST('ref');
$socid=GETPOST('socid');
$action=GETPOST('action');
$confirm=GETPOST('confirm');
$lineid=GETPOST('lineid');
// Security check
$socid=GETPOST('socid');
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'commande',$comid,'');
$result=restrictedArea($user,'commande',$id,'');
$mesg=isset($_GET['mesg'])?$_GET['mesg']:'';
@ -85,7 +88,7 @@ if (! empty($object->hooks))
}
// Action clone object
if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
if ($action == 'confirm_clone' && $confirm == 'yes')
{
if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
{
@ -93,7 +96,7 @@ if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
}
else
{
$result=$object->createFromClone($comid);
$result=$object->createFromClone($id);
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@ -108,15 +111,15 @@ if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
}
// Reopen a closed order
if ($_GET['action'] == 'reopen' && $user->rights->commande->creer)
if ($action == 'reopen' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
if ($object->statut == 3)
{
$result = $object->set_reopen($user);
if ($result > 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$comid);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
else
@ -127,11 +130,11 @@ if ($_GET['action'] == 'reopen' && $user->rights->commande->creer)
}
// Suppression de la commande
if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
if ($action == 'confirm_delete' && $confirm == 'yes')
{
if ($user->rights->commande->supprimer)
{
$object->fetch($comid);
$object->fetch($id);
$result=$object->delete($user);
if ($result > 0)
{
@ -146,14 +149,14 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
}
// Remove a product line
if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes')
if ($action == 'confirm_deleteline' && $confirm == 'yes')
{
if ($user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid']);
$result = $object->deleteline($lineid);
if ($result > 0)
{
// Define output language
@ -173,19 +176,19 @@ if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes'
print $object->error;
}
}
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$comid);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
// Categorisation dans projet
if ($_POST['action'] == 'classin')
if ($action == 'classin')
{
$object->fetch($comid);
$object->fetch($id);
$object->setProject($_POST['projectid']);
}
// Add order
if ($_POST['action'] == 'add' && $user->rights->commande->creer)
if ($action == 'add' && $user->rights->commande->creer)
{
$datecommande = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$datelivraison = dol_mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']);
@ -358,7 +361,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
}
}
$comid = $object_id;
$id = $object_id;
$action = '';
}
@ -379,30 +382,30 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
}
if ($_GET["action"] == 'classifybilled')
if ($action == 'classifybilled')
{
$object->fetch($comid);
$object->fetch($id);
$object->classer_facturee();
}
// Positionne ref commande client
if ($_POST['action'] == 'set_ref_client' && $user->rights->commande->creer)
if ($action == 'set_ref_client' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$object->set_ref_client($user, $_POST['ref_client']);
}
if ($_POST['action'] == 'setremise' && $user->rights->commande->creer)
if ($action == 'setremise' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$object->set_remise($user, $_POST['remise']);
}
if ($_POST['action'] == "setabsolutediscount" && $user->rights->commande->creer)
if ($action == "setabsolutediscount" && $user->rights->commande->creer)
{
if ($_POST["remise_id"])
{
$ret=$object->fetch($comid);
$ret=$object->fetch($id);
if ($ret > 0)
{
$object->insert_discount($_POST["remise_id"]);
@ -414,12 +417,12 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->commande->creer)
}
}
if ($_POST['action'] == 'setdate' && $user->rights->commande->creer)
if ($action == 'setdate' && $user->rights->commande->creer)
{
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$date=dol_mktime(0, 0, 0, $_POST['order_month'], $_POST['order_day'], $_POST['order_year']);
$object->fetch($comid);
$object->fetch($id);
$result=$object->set_date($user,$date);
if ($result < 0)
{
@ -427,12 +430,12 @@ if ($_POST['action'] == 'setdate' && $user->rights->commande->creer)
}
}
if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer)
if ($action == 'setdate_livraison' && $user->rights->commande->creer)
{
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$datelivraison=dol_mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
$object->fetch($comid);
$object->fetch($id);
$result=$object->set_date_livraison($user,$datelivraison);
if ($result < 0)
{
@ -440,49 +443,49 @@ if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer)
}
}
if ($_POST['action'] == 'setaddress' && $user->rights->commande->creer)
if ($action == 'setaddress' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$object->set_adresse_livraison($user,$_POST['fk_address']);
}
if ($_POST['action'] == 'setmode' && $user->rights->commande->creer)
if ($action == 'setmode' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$result=$object->mode_reglement($_POST['mode_reglement_id']);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($_POST['action'] == 'setavailability' && $user->rights->commande->creer)
if ($action == 'setavailability' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$result=$object->availability($_POST['availability_id']);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer)
if ($action == 'setconditions' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$result=$object->cond_reglement($_POST['cond_reglement_id']);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->facture->creer)
if ($action == 'setremisepercent' && $user->rights->facture->creer)
{
$object->fetch($comid);
$object->fetch($id);
$result = $object->set_remise($user, $_POST['remise_percent']);
}
if ($_REQUEST['action'] == 'setremiseabsolue' && $user->rights->facture->creer)
if ($action == 'setremiseabsolue' && $user->rights->facture->creer)
{
$object->fetch($comid);
$object->fetch($id);
$result = $object->set_remise_absolue($user, $_POST['remise_absolue']);
}
/*
* Ajout d'une ligne produit dans la commande
*/
if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
if ($action == 'addline' && $user->rights->commande->creer)
{
$result=0;
@ -499,7 +502,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
if ($result >= 0 && $_POST['qty'] && (($_POST['np_price'] != '' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod']))
{
$ret=$object->fetch($comid);
$ret=$object->fetch($id);
if ($ret < 0)
{
dol_print_error($db,$object->error);
@ -588,7 +591,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
{
// Insert line
$result = $object->addline(
$comid,
$id,
$desc,
$pu_ht,
$_POST['qty'],
@ -644,9 +647,9 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
/*
* Mise a jour d'une ligne dans la commande
*/
if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save'))
if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save'))
{
if (! $object->fetch($comid) > 0) dol_print_error($db);
if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty();
// Clean parameters
@ -739,15 +742,15 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
}
}
if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel'))
if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel'))
{
Header('Location: fiche.php?id='.$comid); // Pour reaffichage de la fiche en cours d'edition
Header('Location: fiche.php?id='.$id); // Pour reaffichage de la fiche en cours d'edition
exit;
}
if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->valider)
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider)
{
$object->fetch($comid); // Load order and lines
$object->fetch($id); // Load order and lines
$object->fetch_thirdparty();
$result=$object->valid($user);
@ -767,26 +770,26 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' &
}
}
if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->cloturer)
if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer)
{
$object->fetch($comid); // Load order and lines
$object->fetch($id); // Load order and lines
$result = $object->cloture($user);
}
if ($_REQUEST['action'] == 'confirm_cancel' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->valider)
if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider)
{
$object->fetch($comid); // Load order and lines
$object->fetch($id); // Load order and lines
$result = $object->cancel($user);
}
if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
if ($action == 'modif' && $user->rights->commande->creer)
{
/*
* Repasse la commande en mode brouillon
*/
$object->fetch($comid); // Load order and lines
$object->fetch($id); // Load order and lines
$object->fetch_thirdparty();
$result = $object->set_draft($user);
@ -810,9 +813,9 @@ if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
* Ordonnancement des lignes
*/
if ($_GET['action'] == 'up' && $user->rights->commande->creer)
if ($action == 'up' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$object->fetch_thirdparty();
$object->line_up($_GET['rowid']);
@ -829,13 +832,13 @@ if ($_GET['action'] == 'up' && $user->rights->commande->creer)
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'));
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$comid.'#'.$_GET['rowid']);
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.$_GET['rowid']);
exit;
}
if ($_GET['action'] == 'down' && $user->rights->commande->creer)
if ($action == 'down' && $user->rights->commande->creer)
{
$object->fetch($comid);
$object->fetch($id);
$object->fetch_thirdparty();
$object->line_down($_GET['rowid']);
@ -851,11 +854,11 @@ if ($_GET['action'] == 'down' && $user->rights->commande->creer)
}
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'));
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$comid.'#'.$_GET['rowid']);
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.$_GET['rowid']);
exit;
}
if ($_REQUEST['action'] == 'builddoc') // In get or post
if ($action == 'builddoc') // In get or post
{
/*
* Generate order document
@ -863,7 +866,7 @@ if ($_REQUEST['action'] == 'builddoc') // In get or post
*/
// Sauvegarde le dernier modele choisi pour generer un document
$result=$object->fetch($comid);
$result=$object->fetch($id);
$object->fetch_thirdparty();
if ($_REQUEST['model'])
@ -895,7 +898,7 @@ if ($_REQUEST['action'] == 'builddoc') // In get or post
}
// Remove file in doc form
if ($_REQUEST['action'] == 'remove_file')
if ($action == 'remove_file')
{
if ($object->fetch($id))
{
@ -945,11 +948,11 @@ if (! empty($_POST['removedfile']))
/*
* Send mail
*/
if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
{
$langs->load('mails');
$result=$object->fetch($_POST['orderid']);
$result=$object->fetch($id);
$result=$object->fetch_thirdparty();
if ($result > 0)
@ -1113,7 +1116,7 @@ $formorder = new FormOrder($db);
* Mode creation
*
*********************************************************************/
if ($_GET['action'] == 'create' && $user->rights->commande->creer)
if ($action == 'create' && $user->rights->commande->creer)
{
print_fiche_titre($langs->trans('CreateOrder'));
@ -1409,16 +1412,13 @@ else
/* *************************************************************************** */
$now=dol_now();
$id = $comid;
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg.'<br>';
$product_static=new Product($db);
$result=$object->fetch($comid,$ref);
$result=$object->fetch($id,$ref);
if ($result > 0)
{
$soc = new Societe($db);
@ -1819,7 +1819,7 @@ else
print '<table id="tablelines" class="noborder" width="100%">';
// Show object lines
if (! empty($object->lines)) $object->printObjectLines(GETPOST('action'),$mysoc,$soc,GETPOST('lineid'),1);
if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1);
/*
* Form to add new line
@ -1857,9 +1857,9 @@ else
/*
* Boutons actions
*/
if ($_GET['action'] != 'presend')
if ($action != 'presend')
{
if ($user->societe_id == 0 && $_GET['action'] <> 'editline')
if ($user->societe_id == 0 && $action <> 'editline')
{
print '<div class="tabsAction">';
@ -1904,7 +1904,7 @@ else
/*$error = $user->load_entrepots(); deprecated
if (sizeof($user->entrepots) === 1)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$comid.'&amp;action=create&amp;commande_id='.$comid.'&entrepot_id='.$user->entrepots[0]['id'].'">';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$id.'&amp;action=create&amp;commande_id='.$id.'&entrepot_id='.$user->entrepots[0]['id'].'">';
print $langs->trans('ShipProduct').'</a>';
}
@ -1980,7 +1980,7 @@ else
}
if ($_GET['action'] != 'presend')
if ($action != 'presend')
{
print '<table width="100%"><tr><td width="50%" valign="top">';
print '<a name="builddoc"></a>'; // ancre
@ -2033,7 +2033,7 @@ else
* Action presend
*
*/
if ($_GET['action'] == 'presend')
if ($action == 'presend')
{
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';

View File

@ -53,14 +53,17 @@ if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['mes
$sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']);
$projectid=isset($_GET['projectid'])?$_GET['projectid']:0;
$id=(GETPOST('id')?GETPOST("id"):GETPOST("facid")); // For backward compatibility
$ref=GETPOST('ref');
$socid=GETPOST('socid');
$action=GETPOST('action');
$confirm=GETPOST('confirm');
$lineid=GETPOST('lineid');
// Security check
$socid=GETPOST("socid");
$facid=GETPOST("id");
if (empty($facid)) $facid=GETPOST("facid"); // For backward compatibility
$ref=GETPOST("ref");
$fieldid = isset($_GET["ref"])?'facnumber':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'facture', $facid,'','','fk_soc',$fieldid);
$result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid);
// Nombre de ligne pour choix de produit/service predefinis
$NBLINES=4;
@ -92,7 +95,7 @@ if (! empty($object->hooks))
}
// Action clone object
if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
if ($action == 'confirm_clone' && $confirm == 'yes')
{
if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
{
@ -100,7 +103,7 @@ if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
}
else
{
$result=$object->createFromClone($facid);
$result=$object->createFromClone($id);
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result);
@ -109,21 +112,21 @@ if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
else
{
$mesg=$object->error;
$_GET['action']='';
$action='';
}
}
}
if ($_GET['action'] == 'reopen' && $user->rights->facture->creer)
if ($action == 'reopen' && $user->rights->facture->creer)
{
$result = $object->fetch($facid);
$result = $object->fetch($id);
if ($object->statut == 2
|| ($object->statut == 3 && $object->close_code != 'replaced'))
{
$result = $object->set_unpaid($user);
if ($result > 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid);
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
else
@ -134,11 +137,11 @@ if ($_GET['action'] == 'reopen' && $user->rights->facture->creer)
}
// Suppression de la facture
if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->facture->supprimer)
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer)
{
if ($user->rights->facture->supprimer)
{
$result = $object->fetch($facid);
$result = $object->fetch($id);
$result = $object->delete();
if ($result > 0)
{
@ -155,11 +158,11 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' &&
/*
* Supprime une ligne produit AVEC ou SANS confirmation
*/
if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes')
if ($action == 'confirm_deleteline' && $confirm == 'yes')
{
if ($user->rights->facture->creer)
{
$object->fetch($facid);
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid'], $user);
@ -178,20 +181,20 @@ if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes'
$result=facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'));
if ($result > 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid);
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
}
else
{
$mesg='<div clas="error">'.$object->error.'</div>';
$_GET['action']='';
$action='';
}
}
}
// Supprime affectation d'un avoir a la facture
if ($_GET['action'] == 'unlinkdiscount')
if ($action == 'unlinkdiscount')
{
if ($user->rights->facture->creer)
{
@ -202,9 +205,9 @@ if ($_GET['action'] == 'unlinkdiscount')
}
// Validation
if ($_GET['action'] == 'valid')
if ($action == 'valid')
{
$object->fetch($facid);
$object->fetch($id);
// On verifie signe facture
if ($object->type == 2)
@ -213,7 +216,7 @@ if ($_GET['action'] == 'valid')
if ($object->total_ht >= 0)
{
$mesg='<div class="error">'.$langs->trans("ErrorInvoiceAvoirMustBeNegative").'</div>';
$_GET['action']='';
$action='';
}
}
else
@ -222,60 +225,60 @@ if ($_GET['action'] == 'valid')
if ($object->total_ht < 0)
{
$mesg='<div class="error">'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'</div>';
$_GET['action']='';
$action='';
}
}
}
if ($_POST['action'] == 'classin')
if ($action == 'classin')
{
$object->fetch($facid);
$object->fetch($id);
$object->setProject($_POST['projectid']);
}
if ($_POST['action'] == 'setmode')
if ($action == 'setmode')
{
$object->fetch($facid);
$object->fetch($id);
$result=$object->mode_reglement($_POST['mode_reglement_id']);
if ($result < 0) dol_print_error($object->db,$object->error);
}
if ($_POST['action'] == 'setinvoicedate')
if ($action == 'setinvoicedate')
{
$object->fetch($facid);
$object->fetch($id);
$object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']);
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date;
$result=$object->update($user);
if ($result < 0) dol_print_error($object->db,$object->error);
}
if ($_POST['action'] == 'setpaymentterm')
if ($action == 'setpaymentterm')
{
$object->fetch($facid);
$object->fetch($id);
$date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']);
$result=$object->cond_reglement($object->cond_reglement_id,$date_lim_reglement);
if ($result < 0) dol_print_error($object->db,$object->error);
}
if ($_POST['action'] == 'setconditions')
if ($action == 'setconditions')
{
$object->fetch($facid);
$object->fetch($id);
$result=$object->cond_reglement($_POST['cond_reglement_id']);
if ($result < 0) dol_print_error($object->db,$object->error);
}
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->facture->creer)
if ($action == 'setremisepercent' && $user->rights->facture->creer)
{
$object->fetch($facid);
$object->fetch($id);
$result = $object->set_remise($user, $_POST['remise_percent']);
}
if ($_POST['action'] == "setabsolutediscount" && $user->rights->facture->creer)
if ($action == "setabsolutediscount" && $user->rights->facture->creer)
{
// POST[remise_id] ou POST[remise_id_for_payment]
if (! empty($_POST["remise_id"]))
{
$ret=$object->fetch($facid);
$ret=$object->fetch($id);
if ($ret > 0)
{
$result=$object->insert_discount($_POST["remise_id"]);
@ -295,7 +298,7 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->facture->creer)
$discount = new DiscountAbsolute($db);
$discount->fetch($_POST["remise_id_for_payment"]);
$result=$discount->link_to_invoice(0,$facid);
$result=$discount->link_to_invoice(0,$id);
if ($result < 0)
{
$mesg='<div class="error">'.$discount->error.'</div>';
@ -303,16 +306,16 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->facture->creer)
}
}
if ($_POST['action'] == 'set_ref_client')
if ($action == 'set_ref_client')
{
$object->fetch($facid);
$object->fetch($id);
$object->set_ref_client($_POST['ref_client']);
}
// Classify to validated
if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $user->rights->facture->valider)
if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider)
{
$object->fetch($facid);
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->validate($user);
@ -337,9 +340,9 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $
}
// Repasse la facture en mode brouillon (unvalidate)
if ($_GET['action'] == 'modif' && $user->rights->facture->unvalidate)
if ($action == 'modif' && $user->rights->facture->unvalidate)
{
$object->fetch($facid);
$object->fetch($id);
$object->fetch_thirdparty();
// On verifie si la facture a des paiements
@ -390,15 +393,15 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->unvalidate)
}
// Classify "paid"
if ($_REQUEST['action'] == 'confirm_paid' && $_REQUEST['confirm'] == 'yes' && $user->rights->facture->paiement)
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement)
{
$object->fetch($facid);
$object->fetch($id);
$result = $object->set_paid($user);
}
// Classif "paid partialy"
if ($_REQUEST['action'] == 'confirm_paid_partially' && $_REQUEST['confirm'] == 'yes' && $user->rights->facture->paiement)
if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement)
{
$object->fetch($facid);
$object->fetch($id);
$close_code=$_POST["close_code"];
$close_note=$_POST["close_note"];
if ($close_code)
@ -411,9 +414,9 @@ if ($_REQUEST['action'] == 'confirm_paid_partially' && $_REQUEST['confirm'] == '
}
}
// Classify "abandoned"
if ($_REQUEST['action'] == 'confirm_canceled' && $_REQUEST['confirm'] == 'yes')
if ($action == 'confirm_canceled' && $confirm == 'yes')
{
$object->fetch($facid);
$object->fetch($id);
$close_code=$_POST["close_code"];
$close_note=$_POST["close_note"];
if ($close_code)
@ -427,11 +430,11 @@ if ($_REQUEST['action'] == 'confirm_canceled' && $_REQUEST['confirm'] == 'yes')
}
// Convertir en reduc
if ($_REQUEST['action'] == 'confirm_converttoreduc' && $_REQUEST['confirm'] == 'yes' && $user->rights->facture->creer)
if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
{
$db->begin();
$object->fetch($facid);
$object->fetch($id);
$object->fetch_thirdparty();
$object->fetch_lines();
@ -503,7 +506,7 @@ if ($_REQUEST['action'] == 'confirm_converttoreduc' && $_REQUEST['confirm'] == '
/*
* Insert new invoice in database
*/
if ($_POST['action'] == 'add' && $user->rights->facture->creer)
if ($action == 'add' && $user->rights->facture->creer)
{
$object->socid=GETPOST('socid');
@ -547,8 +550,8 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$object->fk_facture_source = $_POST['fac_replacement'];
$object->type = 1;
$facid=$object->createFromCurrent($user);
if ($facid <= 0) $mesg=$object->error;
$id=$object->createFromCurrent($user);
if ($id <= 0) $mesg=$object->error;
}
}
@ -592,7 +595,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$object->fk_facture_source = $_POST['fac_avoir'];
$object->type = 2;
$facid = $object->create($user);
$id = $object->create($user);
// Add predefined lines
for ($i = 1; $i <= $NBLINES; $i++)
@ -603,7 +606,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$product->fetch($_POST['idprod'.$i]);
$startday=dol_mktime(12, 0 , 0, $_POST['date_start'.$i.'month'], $_POST['date_start'.$i.'day'], $_POST['date_start'.$i.'year']);
$endday=dol_mktime(12, 0 , 0, $_POST['date_end'.$i.'month'], $_POST['date_end'.$i.'day'], $_POST['date_end'.$i.'year']);
$result=$object->addline($facid,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
$result=$object->addline($id,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
}
}
}
@ -633,7 +636,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
// Source facture
$object->fac_rec = $_POST['fac_rec'];
$facid = $object->create($user);
$id = $object->create($user);
}
}
@ -684,9 +687,9 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$object->origin = $_POST['origin'];
$object->origin_id = $_POST['originid'];
$facid = $object->create($user);
$id = $object->create($user);
if ($facid > 0)
if ($id > 0)
{
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
@ -723,7 +726,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
}
$result = $object->addline(
$facid,
$id,
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
@ -764,7 +767,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
{
foreach($object->hooks as $module)
{
$res = $module->createfrom($srcobject,$facid,$object->element);
$res = $module->createfrom($srcobject,$id,$object->element);
if ($res < 0) $error++;
}
}
@ -784,7 +787,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
// If some invoice's lines already known
else
{
$facid = $object->create($user);
$id = $object->create($user);
for ($i = 1; $i <= $NBLINES; $i++)
{
@ -794,7 +797,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$product->fetch($_POST['idprod'.$i]);
$startday=dol_mktime(12, 0 , 0, $_POST['date_start'.$i.'month'], $_POST['date_start'.$i.'day'], $_POST['date_start'.$i.'year']);
$endday=dol_mktime(12, 0 , 0, $_POST['date_end'.$i.'month'], $_POST['date_end'.$i.'day'], $_POST['date_end'.$i.'year']);
$result=$object->addline($facid,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
$result=$object->addline($id,$product->description,$product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
}
}
}
@ -802,10 +805,10 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
}
// End of object creation, we show it
if ($facid > 0 && ! $error)
if ($id > 0 && ! $error)
{
$db->commit();
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid);
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
else
@ -819,7 +822,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
}
// Add a new line
if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $user->rights->facture->creer)
if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer)
{
$result=0;
@ -845,7 +848,7 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
}
if ($result >= 0 && ( ($_POST['np_price']!='' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod'] ) )
{
$ret=$object->fetch($facid);
$ret=$object->fetch($id);
if ($ret < 0)
{
dol_print_error($db,$object->error);
@ -941,7 +944,7 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
{
// Insert line
$result = $object->addline(
$facid,
$id,
$desc,
$pu_ht,
$_POST['qty'],
@ -994,9 +997,9 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
$_POST["action"]='';
}
if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save'))
if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save'))
{
if (! $object->fetch($facid) > 0) dol_print_error($db);
if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty();
// Clean parameters
@ -1077,9 +1080,9 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
}
}
if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel'))
if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel'))
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid); // Pour reaffichage de la fiche en cours d'edition
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // Pour reaffichage de la fiche en cours d'edition
exit;
}
@ -1088,9 +1091,9 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
* Ordonnancement des lignes
*/
if ($_GET['action'] == 'up' && $user->rights->facture->creer)
if ($action == 'up' && $user->rights->facture->creer)
{
$object->fetch($facid);
$object->fetch($id);
$object->fetch_thirdparty();
$object->line_up($_GET['rowid']);
@ -1110,9 +1113,9 @@ if ($_GET['action'] == 'up' && $user->rights->facture->creer)
exit;
}
if ($_GET['action'] == 'down' && $user->rights->facture->creer)
if ($action == 'down' && $user->rights->facture->creer)
{
$object->fetch($facid);
$object->fetch($id);
$object->fetch_thirdparty();
$object->line_down($_GET['rowid']);
@ -1169,13 +1172,13 @@ if (! empty($_POST['removedfile']))
/*
* Send mail
*/
if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
{
$langs->load('mails');
$actiontypecode='';$subject='';$actionmsg='';$actionmsg2='';
$result=$object->fetch($facid);
$result=$object->fetch($id);
$result=$object->fetch_thirdparty();
if ($result > 0)
@ -1216,7 +1219,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
$sendtocc = $_POST['sendtocc'];
$deliveryreceipt = $_POST['deliveryreceipt'];
if ($_POST['action'] == 'send')
if ($action == 'send')
{
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
else $subject = $langs->transnoentities('Bill').' '.$object->ref;
@ -1230,7 +1233,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
}
//$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
}
if ($_POST['action'] == 'relance')
if ($action == 'relance')
{
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
else $subject = $langs->transnoentities('Relance facture '.$object->ref);
@ -1334,7 +1337,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
}
$_GET['action'] = 'presend';
$action = 'presend';
}
/*
@ -1342,7 +1345,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
*/
if (GETPOST('action') == 'builddoc') // En get ou en post
{
$object->fetch($facid);
$object->fetch($id);
$object->fetch_thirdparty();
if (GETPOST('model'))
@ -1391,7 +1394,7 @@ $now=dol_now();
* Mode creation
*
**********************************************************************/
if ($_GET['action'] == 'create')
if ($action == 'create')
{
$facturestatic=new Facture($db);
@ -1827,10 +1830,6 @@ else
/*
* Show object in view mode
*/
$id = $facid;
$ref= GETPOST('ref');
if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg.'<br>';
@ -1878,7 +1877,7 @@ else
dol_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'), 0, 'bill');
// Confirmation de la conversion de l'avoir en reduc
if ($_GET['action'] == 'converttoreduc')
if ($action == 'converttoreduc')
{
$text=$langs->trans('ConfirmConvertToReduc');
$ret=$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('ConvertToReduc'),$text,'confirm_converttoreduc','',"yes",2);
@ -1886,7 +1885,7 @@ else
}
// Confirmation to delete invoice
if ($_GET['action'] == 'delete')
if ($action == 'delete')
{
$text=$langs->trans('ConfirmDeleteBill');
$ret=$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete','',0,1);
@ -1894,7 +1893,7 @@ else
}
// Confirmation de la validation
if ($_GET['action'] == 'valid')
if ($action == 'valid')
{
// on verifie si l'objet est en numerotation provisoire
$objectref = substr($object->ref, 1, 4);
@ -1928,12 +1927,12 @@ else
}
// Confirmation du classement paye
if ($_GET['action'] == 'paid' && $resteapayer <= 0)
if ($action == 'paid' && $resteapayer <= 0)
{
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ClassifyPaid'),$langs->trans('ConfirmClassifyPaidBill',$object->ref),'confirm_paid','',"yes",1);
if ($ret == 'html') print '<br>';
}
if ($_GET['action'] == 'paid' && $resteapayer > 0)
if ($action == 'paid' && $resteapayer > 0)
{
// Code
$i=0;
@ -1965,7 +1964,7 @@ else
}
// Confirmation du classement abandonne
if ($_GET['action'] == 'canceled')
if ($action == 'canceled')
{
// S'il y a une facture de remplacement pas encore validee (etat brouillon),
// on ne permet pas de classer abandonner la facture.
@ -2007,7 +2006,7 @@ else
}
// Confirmation de la suppression d'une ligne produit
if ($_GET['action'] == 'ask_deleteline')
if ($action == 'ask_deleteline')
{
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
if ($ret == 'html') print '<br>';
@ -2016,7 +2015,7 @@ else
/*
* TODO ajout temporaire pour test en attendant la migration en template
*/
if ($_GET['action'] == 'ask_deletemilestone')
if ($action == 'ask_deletemilestone')
{
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteMilestone'), $langs->trans('ConfirmDeleteMilestone'), 'confirm_deletemilestone','',0,1);
if ($ret == 'html') print '<br>';
@ -2196,13 +2195,13 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Date');
print '</td>';
if ($object->type != 2 && $_GET['action'] != 'editinvoicedate' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editinvoicedate&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
if ($object->type != 2 && $action != 'editinvoicedate' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editinvoicedate&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($object->type != 2)
{
if ($_GET['action'] == 'editinvoicedate')
if ($action == 'editinvoicedate')
{
$html->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date,'invoicedate');
}
@ -2392,12 +2391,12 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateMaxPayment');
print '</td>';
if ($object->type != 2 && $_GET['action'] != 'editpaymentterm' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editpaymentterm&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
if ($object->type != 2 && $action != 'editpaymentterm' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editpaymentterm&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($object->type != 2)
{
if ($_GET['action'] == 'editpaymentterm')
if ($action == 'editpaymentterm')
{
$html->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->date_lim_reglement,'paymentterm');
}
@ -2418,12 +2417,12 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort');
print '</td>';
if ($object->type != 2 && $_GET['action'] != 'editconditions' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
if ($object->type != 2 && $action != 'editconditions' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($object->type != 2)
{
if ($_GET['action'] == 'editconditions')
if ($action == 'editconditions')
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
}
@ -2443,10 +2442,10 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($_GET['action'] != 'editmode' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
if ($action != 'editmode' && $object->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editmode')
if ($action == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
}
@ -2497,7 +2496,7 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Project');
print '</td>';
if ($_GET['action'] != 'classin')
if ($action != 'classin')
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classin&amp;facid='.$object->id.'">';
print img_edit($langs->trans('SetProject'),1);
@ -2506,7 +2505,7 @@ else
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'classin')
if ($action == 'classin')
{
$html->form_project($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->socid,$object->fk_project,'projectid');
}
@ -2534,12 +2533,12 @@ else
print '<table id="tablelines" class="noborder" width="100%">';
// Show object lines
if (! empty($object->lines)) $object->printObjectLines(GETPOST('action'),$mysoc,$soc,GETPOST('lineid'),1);
if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1);
/*
* Form to add new line
*/
if ($object->statut == 0 && $user->rights->facture->creer && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline')
if ($object->statut == 0 && $user->rights->facture->creer && $action <> 'valid' && $action <> 'editline')
{
$var=true;
@ -2572,9 +2571,9 @@ else
* Boutons actions
*/
if ($_GET['action'] != 'prerelance' && $_GET['action'] != 'presend')
if ($action != 'prerelance' && $action != 'presend')
{
if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline')
if ($user->societe_id == 0 && $action <> 'valid' && $action <> 'editline')
{
print '<div class="tabsAction">';
@ -2773,7 +2772,7 @@ else
}
if ($_GET['action'] != 'prerelance' && $_GET['action'] != 'presend')
if ($action != 'prerelance' && $action != 'presend')
{
print '<table width="100%"><tr><td width="50%" valign="top">';
print '<a name="builddoc"></a>'; // ancre
@ -2826,13 +2825,13 @@ else
* Affiche formulaire mail
*/
// By default if $_GET['action']=='presend'
// By default if $action=='presend'
$titreform='SendBillByMail';
$topicmail='SendBillRef';
$action='send';
$modelmail='facture_send';
if ($_GET['action'] == 'prerelance') // For backward compatibility
if ($action == 'prerelance') // For backward compatibility
{
$titrefrom='SendReminderBillByMail';
$topicmail='SendReminderBillRef';

View File

@ -948,7 +948,7 @@ class Form
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='". $langs->getDefaultLang() ."'";
}
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= ' WHERE p.entity IN (0,'.(! empty($conf->entities['product']) ? $conf->entities['product'] : $conf->entity).')';
if (empty($user->rights->produit->hidden) && empty($user->rights->service->hidden)) $sql.=' AND p.hidden=0';
else
{
@ -974,8 +974,8 @@ class Form
{
if ($filterkey && $filterkey != '')
{
$sql.=" AND (p.ref like '".$filterkey."%' OR p.label like '".$filterkey."%'";
if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label like '".$filterkey."%'";
$sql.=" AND (p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%'";
if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '".$filterkey."%'";
$sql.=")";
}
}
@ -983,8 +983,8 @@ class Form
{
if ($filterkey && $filterkey != '')
{
$sql.=" AND (p.ref like '%".$filterkey."%' OR p.label like '%".$filterkey."%'";
if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label like '%".$filterkey."%'";
$sql.=" AND (p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%'";
if ($conf->global->MAIN_MULTILANGS) $sql.=" OR pl.label LIKE '%".$filterkey."%'";
$sql.=")";
}
}

View File

@ -236,10 +236,10 @@ class pdf_edison extends ModelePDFCommandes
$nexY+=2; // Passe espace entre les lignes
// cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1)) // If it's not last line
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $outputlangs->convToOutputCharset($object->lines[$i+1]->desc);
$follow_descproduitservice = $object->lines[$i+1]->desc;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
}

View File

@ -309,10 +309,10 @@ class pdf_einstein extends ModelePDFCommandes
$nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1)) // If it's not last line
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $outputlangs->convToOutputCharset($object->lines[$i+1]->desc);
$follow_descproduitservice = $object->lines[$i+1]->desc;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
// Et si on affiche dates de validite, on ajoute encore une ligne

View File

@ -319,7 +319,7 @@ class pdf_crabe extends ModelePDFFactures
$nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1)) // If it's not last line
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;

View File

@ -223,7 +223,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblines - 1)) // If it's not last line
if ($i < ($nblines - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;

View File

@ -289,7 +289,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblines - 1)) // If it's not last line
if ($i < ($nblines - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;

View File

@ -240,10 +240,10 @@ class pdf_baleine extends ModelePDFProjects
$nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1)) // If it's not last line
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->label;
$follow_descproduitservice = $object->lines[$i+1]->desc;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
}

View File

@ -301,7 +301,7 @@ class pdf_propale_azur extends ModelePDFPropales
$nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1)) // If it's not last line
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;