Task # 1011 : add payment terms and payment mode on supplier card

This commit is contained in:
Maxime Kohlhaas 2013-07-30 15:06:57 +02:00
parent 1b54efcaaf
commit dae36229a4
5 changed files with 68 additions and 3 deletions

View File

@ -916,6 +916,7 @@ abstract class CommonObject
// TODO uniformize field name
$fieldname = 'fk_mode_reglement';
if ($this->element == 'societe') $fieldname = 'mode_reglement';
if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id;
@ -955,6 +956,7 @@ abstract class CommonObject
// TODO uniformize field name
$fieldname = 'fk_cond_reglement';
if ($this->element == 'societe') $fieldname = 'cond_reglement';
if (get_class($this) == 'Fournisseur') $fieldname = 'cond_reglement_supplier';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id;

View File

@ -63,7 +63,20 @@ if ($action == 'setsupplieraccountancycode')
}
$action="";
}
// conditions de reglement
if ($action == 'setconditions' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_supplier_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// mode de reglement
if ($action == 'setmode' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
/*
@ -90,7 +103,7 @@ if ($object->fetch($id))
//print '<tr><td valign="top" width="50%" class="notopnoleft">';
print '<table width="100%" class="border">';
print '<tr><td width="20%">'.$langs->trans("ThirdPartyName").'</td><td width="80%" colspan="3">';
print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">';
$object->next_prev_filter="te.fournisseur = 1";
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
@ -193,6 +206,46 @@ if ($object->fetch($id))
print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td colspan="3">';
print $object->tva_intra;
print '</td></tr>';
// Conditions de reglement par defaut
$langs->load('bills');
$form = new Form($db);
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('PaymentConditions');
print '<td>';
if (($action != 'editconditions') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editconditions')
{
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->cond_reglement_supplier_id,'cond_reglement_supplier_id',-1,1);
}
else
{
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->cond_reglement_supplier_id,'none');
}
print "</td>";
print '</tr>';
// Mode de reglement par defaut
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('PaymentMode');
print '<td>';
if (($action != 'editmode') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editmode')
{
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_supplier_id,'mode_reglement_supplier_id');
}
else
{
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_supplier_id,'none');
}
print "</td>";
print '</tr>';
// Module Adherent
if (! empty($conf->adherent->enabled))

View File

@ -280,3 +280,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc
ALTER TABLE llx_bordereau_cheque ADD ref_ext VARCHAR(255);
ALTER TABLE llx_bordereau_cheque ADD tms timestamp;
-- Task 1011
ALTER TABLE `llx_societe` ADD `mode_reglement_supplier` TINYINT NOT NULL AFTER `cond_reglement` ,
ADD `cond_reglement_supplier` TINYINT NOT NULL AFTER `mode_reglement_supplier`;

View File

@ -77,6 +77,8 @@ create table llx_societe
remise_client real DEFAULT 0, -- remise systematique pour le client
mode_reglement tinyint, -- mode de reglement
cond_reglement tinyint, -- condition de reglement
mode_reglement_supplier tinyint, -- mode de reglement fournisseur
cond_reglement_supplier tinyint, -- condition de reglement fournisseur
tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA
localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1
localtax2_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 2

View File

@ -106,6 +106,8 @@ class Societe extends CommonObject
var $remise_percent;
var $mode_reglement_id;
var $cond_reglement_id;
var $mode_reglement_supplier_id;
var $cond_reglement_supplier_id;
var $client; // 0=no customer, 1=customer, 2=prospect, 3=customer and prospect
var $prospect; // 0=no prospect, 1=prospect
@ -707,7 +709,7 @@ class Societe extends CommonObject
$sql .= ', s.fk_forme_juridique as forme_juridique_code';
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
$sql .= ', s.localtax1_assuj, s.localtax2_assuj, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax2_assuj, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.import_key, s.canvas';
$sql .= ', fj.libelle as forme_juridique';
$sql .= ', e.libelle as effectif';
@ -826,6 +828,8 @@ class Societe extends CommonObject
$this->remise_percent = $obj->remise_client;
$this->mode_reglement_id = $obj->mode_reglement;
$this->cond_reglement_id = $obj->cond_reglement;
$this->mode_reglement_supplier_id = $obj->mode_reglement_supplier;
$this->cond_reglement_supplier_id = $obj->cond_reglement_supplier;
$this->client = $obj->client;
$this->fournisseur = $obj->fournisseur;