diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f4645721185e8e7f1b441fa59873a284d5b81ea6..9fb99f69173ecc174b6aa0a001ed24f8217454a3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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; diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index d61d49476bc5ff015bbfab724c48e22af645e79d..f813d720569ea2ad4bfb2ac0314893e335b77eff 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -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&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&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)) diff --git a/htdocs/install/mysql/migration/3.4.0-3.5.0.sql b/htdocs/install/mysql/migration/3.4.0-3.5.0.sql index f13042bff2e2fc1eeb689c8ef417a1f394d27519..27663a23fafc33809e9af8bfe2509c4fba6aaf8a 100755 --- a/htdocs/install/mysql/migration/3.4.0-3.5.0.sql +++ b/htdocs/install/mysql/migration/3.4.0-3.5.0.sql @@ -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`; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 95ceadec503f3d6ee31367e305b52e5e73456b2b..9348ab3b6d522bc8118cefd116f279ad8e0e1c8d 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -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 diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6278b7bd8ab66776e131ed949ff25cef233e3cda..60e4a1461ad615bf38d136c9aa968f65e8381693 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -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;