Skip to content
Snippets Groups Projects
Commit e9fb0f42 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

New: Add customer invoice ref on invoices

parent 7a2bead1
No related branches found
No related tags found
No related merge requests found
......@@ -143,53 +143,53 @@ else if ($action == 'reopen' && $user->rights->facture->creer)
// Delete invoice
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer)
{
$result = $object->fetch($id);
$result = $object->delete();
if ($result > 0)
{
Header('Location: '.$_SERVER["PHP_SELF"]);
exit;
}
else
{
$mesg='<div class="error">'.$object->error.'</div>';
$result = $object->fetch($id);
$result = $object->delete();
if ($result > 0)
{
Header('Location: '.$_SERVER["PHP_SELF"]);
exit;
}
else
{
$mesg='<div class="error">'.$object->error.'</div>';
}
}
// Delete line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid'], $user);
if ($result > 0)
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
if ($result >= 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
}
else
{
$mesg='<div clas="error">'.$object->error.'</div>';
$action='';
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid'], $user);
if ($result > 0)
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
if ($result >= 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
}
else
{
$mesg='<div clas="error">'.$object->error.'</div>';
$action='';
}
}
......@@ -310,18 +310,18 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer)
$object->set_ref_client($_POST['ref_client']);
}
else if ($action == 'setnote_public' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
else if ($action == 'setnote_public' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
// Classify to validated
......@@ -1506,64 +1506,64 @@ else if ($action == 'builddoc') // En get ou en post
}
}
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
if ($action == 'addcontact' && $user->rights->facture->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
if ($action == 'addcontact' && $user->rights->facture->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->facture->creer)
{
if ($object->fetch($id))
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
dol_print_error($db);
}
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->facture->creer)
{
if ($object->fetch($id))
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
dol_print_error($db);
}
}
}
......@@ -2309,6 +2309,30 @@ else
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
if ($action != 'refclient' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&amp;id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
if ($user->rights->facture->creer && $action == 'refclient')
{
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_ref_client">';
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$object->ref_client.'">';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $object->ref_client;
}
print '</td></tr>';
// Third party
print '<tr><td>';
print '<table class="nobordernopadding" width="100%">';
......@@ -2801,22 +2825,22 @@ else
print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*
......@@ -3502,4 +3526,4 @@ else
llxFooter();
$db->close();
?>
?>
\ No newline at end of file
......@@ -85,9 +85,20 @@ if ($id > 0 || ! empty($ref))
print '<table class="border" width="100%">';
$rowspan=3;
// Reference
// Ref
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$object->ref.'</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Societe
print '<tr><td>'.$langs->trans("Company").'</td>';
print '<td colspan="5">'.$soc->getNomUrl(1,'compta').'</td>';
......
......@@ -161,6 +161,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Customer
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->client->getNomUrl(1,'compta').'</td></tr>';
......
......@@ -169,6 +169,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Company
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
......
......@@ -103,6 +103,17 @@ if ($id > 0 || ! empty($ref))
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>';
// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
// Company
print '<tr><td>'.$langs->trans("Company").'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1,'compta').'</td>';
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment