Uniformize code. Attached fils for supplier invoices are shown on invoice card
This commit is contained in:
parent
bbcefa8864
commit
84bc3f5b31
@ -1009,7 +1009,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
$rowspan=9;
|
||||
|
||||
// Societe
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -1601,14 +1601,14 @@ class Commande extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Commande::cond_reglement Erreur '.$sql.' - '.$this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog('Commande::cond_reglement Erreur '.$sql.' - '.$this->db->error(), LOG_ERR);
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Commande::cond_reglement, etat commande incompatible');
|
||||
dol_syslog('Commande::cond_reglement, etat commande incompatible', LOG_ERR);
|
||||
$this->error='Etat commande incompatible '.$this->statut;
|
||||
return -2;
|
||||
}
|
||||
@ -1635,24 +1635,24 @@ class Commande extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Commande::mode_reglement Erreur '.$sql.' - '.$this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog('Commande::mode_reglement Erreur '.$sql.' - '.$this->db->error(), LOG_ERR);
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Commande::mode_reglement, etat facture incompatible');
|
||||
dol_syslog('Commande::mode_reglement, etat facture incompatible', LOG_ERR);
|
||||
$this->error='Etat commande incompatible '.$this->statut;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Positionne numero reference commande client
|
||||
* \param user Utilisateur qui modifie
|
||||
* \param ref_client Reference commande client
|
||||
* \return int <0 si ko, >0 si ok
|
||||
* \brief Set customer ref
|
||||
* \param user User that make change
|
||||
* \param ref_client Customer ref
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_ref_client($user, $ref_client)
|
||||
{
|
||||
@ -1669,8 +1669,8 @@ class Commande extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog('Commande::set_ref_client Erreur '.$this->error.' - '.$sql);
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog('Commande::set_ref_client Erreur '.$this->error.' - '.$sql, LOG_ERR);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1297,12 +1297,12 @@ else
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">';
|
||||
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=RefCustomerOrder&id='.$commande->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
|
||||
if ($_GET['action'] != 'refcustomer' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcustomer&id='.$commande->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder')
|
||||
if ($user->rights->commande->creer && $_GET['action'] == 'refcustomer')
|
||||
{
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$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="'.$commande->ref_client.'">';
|
||||
|
||||
@ -195,7 +195,7 @@ if ($modulepart)
|
||||
{
|
||||
$accessallowed=1;
|
||||
}
|
||||
$original_file=$conf->fournisseur->dir_output.'/facture/'.$original_file;
|
||||
$original_file=$conf->fournisseur->dir_output.'/facture/'.get_exdir(dirname($original_file),2,1).$original_file;
|
||||
//$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE facnumber='$refname'";
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||
require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php";
|
||||
|
||||
$langs->load('orders');
|
||||
$langs->load('other');
|
||||
$langs->load('sendings');
|
||||
$langs->load('companies');
|
||||
$langs->load('bills');
|
||||
|
||||
@ -187,7 +187,7 @@ if ($id > 0)
|
||||
print "</tr>\n";
|
||||
|
||||
// Third party
|
||||
print "<tr><td>".$langs->trans("Company")."</td>";
|
||||
print "<tr><td>".$langs->trans("Supplier")."</td>";
|
||||
print '<td colspan="3">'.$facture->client->getNomUrl(1,'compta').'</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ if ($_POST['sendit'] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
// Delete
|
||||
if ($action=='delete')
|
||||
{
|
||||
$facid=$_GET["id"];
|
||||
$facid=$_GET['id'];
|
||||
|
||||
$facture = new FactureFournisseur($db);
|
||||
if ($facture->fetch($facid))
|
||||
@ -148,7 +148,7 @@ if ($facid > 0)
|
||||
print "</tr>\n";
|
||||
|
||||
// Societe
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$facture->fournisseur->getNomUrl(1).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="3">'.$facture->fournisseur->getNomUrl(1).'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('NbOfAttachedFiles').'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
require_once('./pre.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/product.class.php');
|
||||
@ -127,7 +128,15 @@ if ($_REQUEST['action'] == 'confirm_paid' && $_REQUEST['confirm'] == 'yes' && $u
|
||||
{
|
||||
$facturefourn=new FactureFournisseur($db);
|
||||
$facturefourn->fetch($_GET['facid']);
|
||||
$facturefourn->set_paid($user);
|
||||
$result=$facturefourn->set_paid($user);
|
||||
}
|
||||
|
||||
// Set supplier ref
|
||||
if ($_POST['action'] == 'set_ref_supplier' && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$facturefourn = new FactureFournisseur($db);
|
||||
$facturefourn->fetch($_GET['facid']);
|
||||
$result=$facturefourn->set_ref_supplier($user, $_POST['ref_supplier']);
|
||||
}
|
||||
|
||||
if($_GET['action'] == 'deletepaiement')
|
||||
@ -397,6 +406,8 @@ if ($_POST['action'] == 'classin')
|
||||
|
||||
llxHeader('','','');
|
||||
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
|
||||
// Mode creation
|
||||
if ($_GET['action'] == 'create')
|
||||
@ -515,8 +526,8 @@ else
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
print '<td>'.$societe->getNomUrl(1).'</td>';
|
||||
print '<td width="50%" valign="top">'.$langs->trans('NotePublic').'</td>';
|
||||
print '</tr>';
|
||||
@ -524,15 +535,15 @@ else
|
||||
// Ref
|
||||
print '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">';
|
||||
print $fac->ref.'</td>';
|
||||
$rownb=10;
|
||||
print '<td rowspan="'.$rownb.'" valign="top">';
|
||||
print '<textarea name="note" wrap="soft" cols="60" rows="'.$rownb.'">';
|
||||
print $fac->note;
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans('RefSupplier').'</td><td valign="top">';
|
||||
print '<input name="facnumber" type="text" value="'.$fac->ref_supplier.'"></td>';
|
||||
|
||||
$rownb=9;
|
||||
print '<td rowspan="'.$rownb.'" valign="top">';
|
||||
print '<textarea name="note" wrap="soft" cols="60" rows="'.ROWS_9.'">';
|
||||
print $fac->note;
|
||||
print '</textarea></td></tr>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans('Label').'</td><td>';
|
||||
print '<input size="30" name="libelle" type="text" value="'.$fac->libelle.'"></td></tr>';
|
||||
@ -665,11 +676,31 @@ else
|
||||
print "</tr>\n";
|
||||
|
||||
// Ref supplier
|
||||
print '<tr><td nowrap="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="4">'.$fac->ref_supplier.'</td>';
|
||||
print "</tr>\n";
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print $langs->trans('RefSupplier').'</td><td align="left">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'refsupplier' && $fac->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refsupplier&facid='.$fac->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($user->rights->fournisseur->facture->creer && $_GET['action'] == 'refsupplier')
|
||||
{
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="set_ref_supplier">';
|
||||
print '<input type="text" class="flat" size="20" name="ref_supplier" value="'.$fac->ref_supplier.'">';
|
||||
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $fac->ref_supplier;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Third party
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="4">'.$societe->getNomUrl(1).' (<a href="index.php?socid='.$fac->socid.'">'.$langs->trans('OtherBills').'</a>)</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="4">'.$societe->getNomUrl(1).' (<a href="index.php?socid='.$fac->socid.'">'.$langs->trans('OtherBills').'</a>)</td></tr>';
|
||||
|
||||
// Type
|
||||
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="4">';
|
||||
@ -1153,6 +1184,42 @@ else
|
||||
print '<a class="butActionDelete" href="fiche.php?facid='.$fac->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
|
||||
|
||||
if ($_GET['action'] != 'presend')
|
||||
{
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
*/
|
||||
$filename=dol_sanitizeFileName($fac->ref);
|
||||
$filedir=$conf->fournisseur->dir_output.'/facture/'.get_exdir($fac->id,2).$fac->id;
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id;
|
||||
//$genallowed=$user->rights->fournisseur->facture->creer;
|
||||
$genallowed=false; // TODO Waiting for supplier invoice generation
|
||||
$delallowed=$user->rights->fournisseur->facture->supprimer;
|
||||
|
||||
$var=true;
|
||||
|
||||
$somethingshown=$formfile->show_documents('facture_fournisseur',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf);
|
||||
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
print '<br>';
|
||||
|
||||
// List of actions on element
|
||||
/*
|
||||
include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php');
|
||||
$formactions=new FormActions($db);
|
||||
$somethingshown=$formactions->showactions($fac,'invoice_supplier',$socid);
|
||||
*/
|
||||
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -109,8 +109,8 @@ if ($_GET["facid"])
|
||||
print '<tr><td nowrap="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="3">'.$fac->ref_supplier.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Soci<EFBFBD>t<EFBFBD>
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$fac->fournisseur->getNomUrl(1).'</td></tr>';
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="3">'.$fac->fournisseur->getNomUrl(1).'</td></tr>';
|
||||
|
||||
// Note publique
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
|
||||
|
||||
@ -409,6 +409,37 @@ class FactureFournisseur extends Facture
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set supplier ref
|
||||
* \param user User that make change
|
||||
* \param ref_supplier Supplier ref
|
||||
* \return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_ref_supplier($user, $ref_supplier)
|
||||
{
|
||||
if ($user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
dol_syslog('FactureFournisseur::set_ref_supplier this->id='.$this->id.', ref_supplier='.$ref_supplier);
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn SET facnumber = '.(empty($ref_supplier) ? 'NULL' : '\''.addslashes($ref_supplier).'\'');
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->ref_supplier = $ref_supplier;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog('FactureFournisseur::set_ref_supplier '.$this->error.' - '.$sql, LOG_ERR);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tag la facture comme payee completement
|
||||
|
||||
Loading…
Reference in New Issue
Block a user