2
0
forked from Wavyzz/dolibarr

Fix: change 'editfieldkey' and 'editfieldval' for compatibility with

external module and hook system.
Fix: uniform code
This commit is contained in:
Regis Houssin
2011-11-09 06:10:31 +08:00
parent da27a55e41
commit cbec43e098
17 changed files with 507 additions and 499 deletions

View File

@@ -49,12 +49,13 @@ if ($conf->notification->enabled) $langs->load("mails");
if (!empty($conf->global->MAIN_MODULE_CHRONODOCS)) $langs->load("chronodocs"); if (!empty($conf->global->MAIN_MODULE_CHRONODOCS)) $langs->load("chronodocs");
// Security check // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:''; $id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id'));
if ($user->societe_id > 0) $socid=$user->societe_id; if ($user->societe_id > 0) $id=$user->societe_id;
$result = restrictedArea($user,'societe',$socid,''); $result = restrictedArea($user,'societe',$id,'');
$mode=GETPOST("mode"); $action = GETPOST('action');
$modesearch=GETPOST("mode_search"); $mode = GETPOST("mode");
$modesearch = GETPOST("mode_search");
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
@@ -66,61 +67,61 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom"; if (! $sortfield) $sortfield="nom";
$object = new Societe($db);
/* /*
* Actions * Actions
*/ */
if ($_POST['action'] == 'setcustomeraccountancycode') if ($action == 'setcustomeraccountancycode')
{ {
$societe = new Societe($db); $result=$object->fetch($id);
$result=$societe->fetch($_POST['socid']); $object->code_compta=$_POST["customeraccountancycode"];
$societe->code_compta=$_POST["customeraccountancycode"]; $result=$object->update($object->id,$user,1,1,0);
$result=$societe->update($societe->id,$user,1,1,0);
if ($result < 0) if ($result < 0)
{ {
$mesg=join(',',$societe->errors); $mesg=join(',',$object->errors);
} }
$POST["action"]=""; $action="";
$socid=$_POST["socid"];
} }
if ($_GET["action"] == 'attribute_prefix' && $user->rights->societe->creer) if ($action == 'attribute_prefix' && $user->rights->societe->creer)
{ {
$societe = new Societe($db); $object->fetch($id);
$societe->fetch($_GET["socid"]); $object->attribute_prefix($db, $id);
$societe->attribute_prefix($db, $_GET["socid"]);
} }
// conditions de reglement // conditions de reglement
if ($_POST["action"] == 'setconditions' && $user->rights->societe->creer) if ($action == 'setconditions' && $user->rights->societe->creer)
{ {
$object->fetch($id);
$societe = new Societe($db); $object->cond_reglement=$_POST['cond_reglement_id'];
$societe->fetch($_GET["socid"]);
$societe->cond_reglement=$_POST['cond_reglement_id']; // TODO move to DAO class
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET cond_reglement='".$_POST['cond_reglement_id']; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET cond_reglement='".$_POST['cond_reglement_id'];
$sql.= "' WHERE rowid='".$_GET["socid"]."'"; $sql.= "' WHERE rowid='".$id."'";
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) dol_print_error($result); if (! $result) dol_print_error($result);
} }
// mode de reglement // mode de reglement
if ($_POST["action"] == 'setmode' && $user->rights->societe->creer) if ($action == 'setmode' && $user->rights->societe->creer)
{ {
$societe = new Societe($db); $obejct->fetch($id);
$societe->fetch($_GET["socid"]); $object->mode_reglement=$_POST['mode_reglement_id'];
$societe->mode_reglement=$_POST['mode_reglement_id'];
// TODO move to DAO class
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET mode_reglement='".$_POST['mode_reglement_id']; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET mode_reglement='".$_POST['mode_reglement_id'];
$sql.= "' WHERE rowid='".$_GET["socid"]."'"; $sql.= "' WHERE rowid='".$id."'";
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) dol_print_error($result); if (! $result) dol_print_error($result);
} }
// assujetissement a la TVA // assujetissement a la TVA
if ($_POST["action"] == 'setassujtva' && $user->rights->societe->creer) if ($action == 'setassujtva' && $user->rights->societe->creer)
{ {
$societe = new Societe($db); $object->fetch($id);
$societe->fetch($_GET["socid"]); $object->tva_assuj=$_POST['assujtva_value'];
$societe->tva_assuj=$_POST['assujtva_value'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$socid."'"; // TODO move to DAO class
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$id."'";
$result = $db->query($sql); $result = $db->query($sql);
if (! $result) dol_print_error($result); if (! $result) dol_print_error($result);
} }
@@ -143,12 +144,13 @@ if ($mode == 'search')
{ {
if ($modesearch == 'soc') if ($modesearch == 'soc')
{ {
// TODO move to DAO class
$sql = "SELECT s.rowid"; $sql = "SELECT s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; if (!$user->rights->societe->client->voir && !$id) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
} }
$resql=$db->query($sql); $resql=$db->query($sql);
@@ -157,22 +159,20 @@ if ($mode == 'search')
if ( $db->num_rows($resql) == 1) if ( $db->num_rows($resql) == 1)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$socid = $obj->rowid; $id = $obj->rowid;
} }
$db->free($resql); $db->free($resql);
} }
} }
if ($socid > 0) if ($id > 0)
{ {
// Load data of third party // Load data of third party
$objsoc = new Societe($db); $object->fetch($id);
$objsoc->id=$socid; if ($object->id <= 0)
$objsoc->fetch($socid,$to);
if ($objsoc->id <= 0)
{ {
dol_print_error($db,$objsoc->error); dol_print_error($db,$object->error);
} }
if ($errmesg) if ($errmesg)
@@ -184,7 +184,7 @@ if ($socid > 0)
* Affichage onglets * Affichage onglets
*/ */
$head = societe_prepare_head($objsoc); $head = societe_prepare_head($object);
dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"),0,'company');
@@ -195,69 +195,70 @@ if ($socid > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">'; print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">';
$objsoc->next_prev_filter="te.client in (1,3)"; $object->next_prev_filter="te.client in (1,3)";
print $form->showrefnav($objsoc,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>'; print '</td></tr>';
// Prefix // Prefix
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{ {
print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
print ($objsoc->prefix_comm?$objsoc->prefix_comm:'&nbsp;'); print ($object->prefix_comm?$object->prefix_comm:'&nbsp;');
print '</td></tr>'; print '</td></tr>';
} }
if ($objsoc->client) if ($object->client)
{ {
$langs->load("compta"); $langs->load("compta");
print '<tr><td nowrap>'; print '<tr><td nowrap>';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $objsoc->code_client; print $object->code_client;
if ($objsoc->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$objsoc->code_compta,'socid',$objsoc->id,$user->rights->societe->creer); print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
print '</td><td colspan="3">'; print '</td><td colspan="3">';
print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$objsoc->code_compta,'socid',$objsoc->id,$user->rights->societe->creer); print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Address // Address
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3">'; print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3">';
dol_print_address($objsoc->address,'gmap','thirdparty',$objsoc->id); dol_print_address($object->address,'gmap','thirdparty',$object->id);
print "</td></tr>"; print "</td></tr>";
// Zip / Town // Zip / Town
print '<tr><td nowrap="nowrap">'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td colspan="3">'.$objsoc->cp.(($objsoc->cp && $objsoc->ville)?' / ':'').$objsoc->ville."</td>"; print '<tr><td nowrap="nowrap">'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td>';
print '<td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town."</td>";
print '</tr>'; print '</tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
$img=picto_from_langcode($objsoc->pays_code); $img=picto_from_langcode($object->country_code);
if ($objsoc->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$objsoc->pays,$langs->trans("CountryIsInEEC"),1,0); if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$objsoc->pays; else print ($img?$img.' ':'').$object->country;
print '</td></tr>'; print '</td></tr>';
// Phone // Phone
print '<tr><td>'.$langs->trans('Phone').'</td><td style="min-width: 25%;">'.dol_print_phone($objsoc->tel,$objsoc->pays_code,0,$objsoc->id,'AC_TEL').'</td>'; print '<tr><td>'.$langs->trans('Phone').'</td><td style="min-width: 25%;">'.dol_print_phone($object->tel,$object->country_code,0,$object->id,'AC_TEL').'</td>';
// Fax // Fax
print '<td>'.$langs->trans('Fax').'</td><td style="min-width: 25%;">'.dol_print_phone($objsoc->fax,$objsoc->pays_code,0,$objsoc->id,'AC_FAX').'</td></tr>'; print '<td>'.$langs->trans('Fax').'</td><td style="min-width: 25%;">'.dol_print_phone($object->fax,$object->country_code,0,$object->id,'AC_FAX').'</td></tr>';
// EMail // EMail
print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($objsoc->email,0,$objsoc->id,'AC_EMAIL').'</td></tr>'; print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($object->email,0,$object->id,'AC_EMAIL').'</td></tr>';
// Web // Web
print '<tr><td>'.$langs->trans("Web").'</td><td colspan="3">'.dol_print_url($objsoc->url,'_blank').'</td></tr>'; print '<tr><td>'.$langs->trans("Web").'</td><td colspan="3">'.dol_print_url($object->url,'_blank').'</td></tr>';
// Assujeti a TVA ou pas // Assujeti a TVA ou pas
print '<tr>'; print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">'; print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
print yn($objsoc->tva_assuj); print yn($object->tva_assuj);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@@ -267,29 +268,29 @@ if ($socid > 0)
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
{ {
print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax1IsUsedES').'</td><td colspan="3">'; print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax1IsUsedES').'</td><td colspan="3">';
print yn($objsoc->localtax1_assuj); print yn($object->localtax1_assuj);
print '</td></tr>'; print '</td></tr>';
print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax2IsUsedES').'</td><td colspan="3">'; print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax2IsUsedES').'</td><td colspan="3">';
print yn($objsoc->localtax2_assuj); print yn($object->localtax2_assuj);
print '</td></tr>'; print '</td></tr>';
} }
elseif($mysoc->localtax1_assuj=="1") elseif($mysoc->localtax1_assuj=="1")
{ {
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
print yn($objsoc->localtax1_assuj); print yn($object->localtax1_assuj);
print '</td></tr>'; print '</td></tr>';
} }
elseif($mysoc->localtax2_assuj=="1") elseif($mysoc->localtax2_assuj=="1")
{ {
print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
print yn($objsoc->localtax2_assuj); print yn($object->localtax2_assuj);
print '</td></tr>'; print '</td></tr>';
} }
} }
// TVA Intra // TVA Intra
print '<tr><td nowrap>'.$langs->trans('VATIntraVeryShort').'</td><td colspan="3">'; print '<tr><td nowrap>'.$langs->trans('VATIntraVeryShort').'</td><td colspan="3">';
print $objsoc->tva_intra; print $object->tva_intra;
print '</td></tr>'; print '</td></tr>';
// Conditions de reglement par defaut // Conditions de reglement par defaut
@@ -299,16 +300,16 @@ if ($socid > 0)
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>'; print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('PaymentConditions'); print $langs->trans('PaymentConditions');
print '<td>'; print '<td>';
if (($_GET['action'] != 'editconditions') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;socid='.$objsoc->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></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 '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'editconditions') if ($action == 'editconditions')
{ {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->cond_reglement,'cond_reglement_id',-1,1); $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->cond_reglement,'cond_reglement_id',-1,1);
} }
else else
{ {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->cond_reglement,'none'); $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->cond_reglement,'none');
} }
print "</td>"; print "</td>";
print '</tr>'; print '</tr>';
@@ -318,16 +319,16 @@ if ($socid > 0)
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>'; print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans('PaymentMode'); print $langs->trans('PaymentMode');
print '<td>'; print '<td>';
if (($_GET['action'] != 'editmode') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;socid='.$objsoc->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></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 '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'editmode') if ($action == 'editmode')
{ {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'mode_reglement_id'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement,'mode_reglement_id');
} }
else else
{ {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement,'none');
} }
print "</td>"; print "</td>";
print '</tr>'; print '</tr>';
@@ -339,10 +340,10 @@ if ($socid > 0)
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0) if ($user->rights->societe->creer && !$user->societe_id > 0)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$objsoc->id.'">'.img_edit($langs->trans("Modify")).'</a>'; print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td><td colspan="3">'.($objsoc->remise_client?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$objsoc->id.'">'.$objsoc->remise_client.'%</a>':$langs->trans("DiscountNone")).'</td>'; print '</td><td colspan="3">'.($object->remise_client?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_client.'%</a>':$langs->trans("DiscountNone")).'</td>';
print '</tr>'; print '</tr>';
// Absolute discounts (Discounts-Drawbacks-Rebates) // Absolute discounts (Discounts-Drawbacks-Rebates)
@@ -353,14 +354,14 @@ if ($socid > 0)
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0) if ($user->rights->societe->creer && !$user->societe_id > 0)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$objsoc->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$objsoc->id).'">'.img_edit($langs->trans("Modify")).'</a>'; print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td>'; print '</td>';
print '<td colspan="3">'; print '<td colspan="3">';
$amount_discount=$objsoc->getAvailableDiscounts(); $amount_discount=$object->getAvailableDiscounts();
if ($amount_discount < 0) dol_print_error($db,$societe->error); if ($amount_discount < 0) dol_print_error($db,$object->error);
if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$objsoc->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$objsoc->id).'">'.price($amount_discount).'</a>&nbsp;'.$langs->trans("Currency".$conf->monnaie); if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount).'</a>&nbsp;'.$langs->trans("Currency".$conf->monnaie);
else print $langs->trans("DiscountNone"); else print $langs->trans("DiscountNone");
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@@ -374,10 +375,10 @@ if ($socid > 0)
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$objsoc->id.'">'.img_edit($langs->trans("Modify")).'</a>'; print '<a href="'.DOL_URL_ROOT.'/comm/multiprix.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td><td colspan="3">'.$objsoc->price_level."</td>"; print '</td><td colspan="3">'.$object->price_level."</td>";
print '</tr>'; print '</tr>';
} }
@@ -391,14 +392,15 @@ if ($socid > 0)
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$objsoc->id.'">'.img_edit($langs->trans("Modify")).'</a>'; print '<a href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
// TODO move to DAO class
$sql = "SELECT count(rowid) as nb"; $sql = "SELECT count(rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_address"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_address";
$sql.= " WHERE fk_soc =".$objsoc->id; $sql.= " WHERE fk_soc =".$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@@ -424,7 +426,7 @@ if ($socid > 0)
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>'; print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
$adh=new Adherent($db); $adh=new Adherent($db);
$result=$adh->fetch('','',$objsoc->id); $result=$adh->fetch('','',$object->id);
if ($result > 0) if ($result > 0)
{ {
$adh->ref=$adh->getFullName($langs); $adh->ref=$adh->getFullName($langs);
@@ -453,7 +455,7 @@ if ($socid > 0)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$objsoc->id.'">'.$langs->trans("ShowCustomerPreview").'</a></td></tr></table></td>'; print '<td align="right"><a href="'.DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id.'">'.$langs->trans("ShowCustomerPreview").'</a></td></tr></table></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@@ -467,7 +469,7 @@ if ($socid > 0)
{ {
$propal_static = new Propal($db); $propal_static = new Propal($db);
$proposals = $propal_static->liste_array(0, 0, 0, $objsoc->id, $MAXLIST); $proposals = $propal_static->liste_array(0, 0, 0, $object->id, $MAXLIST);
//var_dump($proposals); //var_dump($proposals);
@@ -475,7 +477,7 @@ if ($socid > 0)
$sql.= " p.datep as dp, p.fin_validite as datelimite"; $sql.= " p.datep as dp, p.fin_validite as datelimite";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
$sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
$sql.= " AND s.rowid = ".$objsoc->id; $sql.= " AND s.rowid = ".$object->id;
$sql.= " ORDER BY p.datep DESC"; $sql.= " ORDER BY p.datep DESC";
$resql=$db->query($sql); $resql=$db->query($sql);
@@ -489,8 +491,8 @@ if ($socid > 0)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$objsoc->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$object->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$objsoc->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>'; print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
print '</tr>'; print '</tr>';
} }
@@ -500,7 +502,7 @@ if ($socid > 0)
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print "<td nowrap><a href=\"propal.php?id=$objp->propalid\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."</a>\n"; print '<td nowrap><a href="propal.php?id=$objp->propalid">'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.'</a>'."\n";
if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 ) if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 )
{ {
print " ".img_warning(); print " ".img_warning();
@@ -533,7 +535,7 @@ if ($socid > 0)
$sql.= " c.date_commande as dc"; $sql.= " c.date_commande as dc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
$sql.= " WHERE c.fk_soc = s.rowid "; $sql.= " WHERE c.fk_soc = s.rowid ";
$sql.= " AND s.rowid = ".$objsoc->id; $sql.= " AND s.rowid = ".$object->id;
$sql.= " ORDER BY c.date_commande DESC"; $sql.= " ORDER BY c.date_commande DESC";
$resql=$db->query($sql); $resql=$db->query($sql);
@@ -547,8 +549,8 @@ if ($socid > 0)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/liste.php?socid='.$objsoc->id.'">'.$langs->trans("AllOrders").' ('.$num.')</a></td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/liste.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' ('.$num.')</a></td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$objsoc->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>'; print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
print '</tr>'; print '</tr>';
} }
@@ -585,7 +587,7 @@ if ($socid > 0)
$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc"; $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
$sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = ".$objsoc->id; $sql .= " AND s.rowid = ".$object->id;
$sql .= " ORDER BY c.datec DESC"; $sql .= " ORDER BY c.datec DESC";
$resql=$db->query($sql); $resql=$db->query($sql);
@@ -599,7 +601,7 @@ if ($socid > 0)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastContracts",($num<=$MAXLIST?"":$MAXLIST)).'</td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastContracts",($num<=$MAXLIST?"":$MAXLIST)).'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/contrat/liste.php?socid='.$objsoc->id.'">'.$langs->trans("AllContracts").' ('.$num.')</a></td></tr></table></td>'; print '<td align="right"><a href="'.DOL_URL_ROOT.'/contrat/liste.php?socid='.$object->id.'">'.$langs->trans("AllContracts").' ('.$num.')</a></td></tr></table></td>';
print '</tr>'; print '</tr>';
} }
$i = 0; $i = 0;
@@ -642,7 +644,7 @@ if ($socid > 0)
$sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.duree as duration, f.datei as startdate"; $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.duree as duration, f.datei as startdate";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
$sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND s.rowid = ".$objsoc->id; $sql .= " AND s.rowid = ".$object->id;
$sql .= " ORDER BY f.tms DESC"; $sql .= " ORDER BY f.tms DESC";
$fichinter_static=new Fichinter($db); $fichinter_static=new Fichinter($db);
@@ -657,7 +659,7 @@ if ($socid > 0)
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$objsoc->id.'">'.$langs->trans("AllInterventions").' ('.$num.')</td></tr></table></td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'">'.$langs->trans("AllInterventions").' ('.$num.')</td></tr></table></td>';
print '</tr>'; print '</tr>';
$var=!$var; $var=!$var;
} }
@@ -699,7 +701,7 @@ if ($socid > 0)
$sql.= ' SUM(pf.amount) as am'; $sql.= ' SUM(pf.amount) as am';
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$objsoc->id; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,'; $sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
$sql.= ' f.datef, f.datec, f.paye, f.fk_statut,'; $sql.= ' f.datef, f.datec, f.paye, f.fk_statut,';
$sql.= ' s.nom, s.rowid'; $sql.= ' s.nom, s.rowid';
@@ -717,8 +719,8 @@ if ($socid > 0)
$tableaushown=1; $tableaushown=1;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$objsoc->id.'">'.$langs->trans("AllBills").' ('.$num.')</a></td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$object->id.'">'.$langs->trans("AllBills").' ('.$num.')</a></td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$objsoc->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>'; print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>'; print '</tr></table></td>';
print '</tr>'; print '</tr>';
} }
@@ -772,25 +774,25 @@ if ($socid > 0)
if ($conf->propal->enabled && $user->rights->propale->creer) if ($conf->propal->enabled && $user->rights->propale->creer)
{ {
$langs->load("propal"); $langs->load("propal");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$objsoc->id.'&amp;action=create">'.$langs->trans("AddProp").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a>';
} }
if ($conf->commande->enabled && $user->rights->commande->creer) if ($conf->commande->enabled && $user->rights->commande->creer)
{ {
$langs->load("orders"); $langs->load("orders");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socid='.$objsoc->id.'&amp;action=create">'.$langs->trans("AddOrder").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddOrder").'</a>';
} }
if ($user->rights->contrat->creer) if ($user->rights->contrat->creer)
{ {
$langs->load("contracts"); $langs->load("contracts");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?socid='.$objsoc->id.'&amp;action=create">'.$langs->trans("AddContract").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContract").'</a>';
} }
if ($conf->ficheinter->enabled && $user->rights->ficheinter->creer) if ($conf->ficheinter->enabled && $user->rights->ficheinter->creer)
{ {
$langs->load("fichinter"); $langs->load("fichinter");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/fiche.php?socid='.$objsoc->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/fiche.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a>';
} }
// Add invoice // Add invoice
@@ -799,7 +801,7 @@ if ($socid > 0)
if ($conf->deplacement->enabled) if ($conf->deplacement->enabled)
{ {
$langs->load("trips"); $langs->load("trips");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/fiche.php?socid='.$objsoc->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/fiche.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a>';
} }
if ($conf->facture->enabled) if ($conf->facture->enabled)
@@ -807,7 +809,7 @@ if ($socid > 0)
if ($user->rights->facture->creer) if ($user->rights->facture->creer)
{ {
$langs->load("bills"); $langs->load("bills");
if ($objsoc->client != 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$objsoc->id.'">'.$langs->trans("AddBill").'</a>'; if ($object->client != 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>'; else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
} }
else else
@@ -822,7 +824,7 @@ if ($socid > 0)
{ {
if ($user->rights->agenda->myactions->create) if ($user->rights->agenda->myactions->create)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$objsoc->id.'">'.$langs->trans("AddAction").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a>';
} }
else else
{ {
@@ -832,7 +834,7 @@ if ($socid > 0)
/*if ($user->rights->societe->contact->creer) /*if ($user->rights->societe->contact->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$objsoc->id.'&amp;action=create">'.$langs->trans("AddContact").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContact").'</a>';
}*/ }*/
print '</div>'; print '</div>';
@@ -842,16 +844,16 @@ if ($socid > 0)
{ {
print '<br>'; print '<br>';
// List of contacts // List of contacts
show_contacts($conf,$langs,$db,$objsoc,$_SERVER["PHP_SELF"].'?socid='.$objsoc->id); show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
} }
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{ {
// List of todo actions // List of todo actions
show_actions_todo($conf,$langs,$db,$objsoc); show_actions_todo($conf,$langs,$db,$object);
// List of done actions // List of done actions
show_actions_done($conf,$langs,$db,$objsoc); show_actions_done($conf,$langs,$db,$object);
} }
} }
else else

View File

@@ -722,18 +722,18 @@ else
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<tr><td>'.$form->editfieldkey("MailTitle",'desc',$mil->titre,'id',$mil->id,$user->rights->mailing->creer).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("MailTitle",'desc',$mil->titre,$mil,$user->rights->mailing->creer).'</td><td colspan="3">';
print $form->editfieldval("MailTitle",'desc',$mil->titre,'id',$mil->id,$user->rights->mailing->creer); print $form->editfieldval("MailTitle",'desc',$mil->titre,$mil,$user->rights->mailing->creer);
print '</td></tr>'; print '</td></tr>';
// From // From
print '<tr><td>'.$form->editfieldkey("MailFrom",'from',$mil->email_from,'id',$mil->id,$user->rights->mailing->creer && $mil->statut < 3,'email').'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("MailFrom",'from',$mil->email_from,$mil,$user->rights->mailing->creer && $mil->statut < 3,'email').'</td><td colspan="3">';
print $form->editfieldval("MailFrom",'from',$mil->email_from,'id',$mil->id,$user->rights->mailing->creer && $mil->statut < 3,'email'); print $form->editfieldval("MailFrom",'from',$mil->email_from,$mil,$user->rights->mailing->creer && $mil->statut < 3,'email');
print '</td></tr>'; print '</td></tr>';
// Errors to // Errors to
print '<tr><td>'.$form->editfieldkey("MailErrorsTo",'errorsto',$mil->email_errorsto,'id',$mil->id,$user->rights->mailing->creer && $mil->statut < 3,'email').'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("MailErrorsTo",'errorsto',$mil->email_errorsto,$mil,$user->rights->mailing->creer && $mil->statut < 3,'email').'</td><td colspan="3">';
print $form->editfieldval("MailErrorsTo",'errorsto',$mil->email_errorsto,'id',$mil->id,$user->rights->mailing->creer && $mil->statut < 3,'email'); print $form->editfieldval("MailErrorsTo",'errorsto',$mil->email_errorsto,$mil,$user->rights->mailing->creer && $mil->statut < 3,'email');
print '</td></tr>'; print '</td></tr>';
// Status // Status

View File

@@ -381,9 +381,9 @@ else if ($id)
// Type // Type
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey("Type",'type',$langs->trans($object->type),'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'select:types_fees'); print $form->editfieldkey("Type",'type',$langs->trans($object->type),$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'select:types_fees');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("Type",'type',$langs->trans($object->type),'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'select:types_fees'); print $form->editfieldval("Type",'type',$langs->trans($object->type),$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'select:types_fees');
print '</td></tr>'; print '</td></tr>';
// Who // Who
@@ -395,16 +395,16 @@ else if ($id)
// Date // Date
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey("Date",'dated',$object->date,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'datepicker'); print $form->editfieldkey("Date",'dated',$object->date,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'datepicker');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("Date",'dated',$object->date,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'datepicker'); print $form->editfieldval("Date",'dated',$object->date,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'datepicker');
print '</td></tr>'; print '</td></tr>';
// Km/Price // Km/Price
print '<tr><td valign="top">'; print '<tr><td valign="top">';
print $form->editfieldkey("FeesKilometersOrAmout",'km',$object->km,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'numeric:6'); print $form->editfieldkey("FeesKilometersOrAmout",'km',$object->km,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'numeric:6');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("FeesKilometersOrAmout",'km',$object->km,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'numeric:6'); print $form->editfieldval("FeesKilometersOrAmout",'km',$object->km,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'numeric:6');
print "</td></tr>"; print "</td></tr>";
// Where // Where
@@ -448,18 +448,18 @@ else if ($id)
// Public note // Public note
print '<tr><td valign="top">'; print '<tr><td valign="top">';
print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); print $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); print $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180');
print "</td></tr>"; print "</td></tr>";
// Private note // Private note
if (! $user->societe_id) if (! $user->societe_id)
{ {
print '<tr><td valign="top">'; print '<tr><td valign="top">';
print $form->editfieldkey("NotePrivate",'note',$object->note_private,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); print $form->editfieldkey("NotePrivate",'note',$object->note_private,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180');
print '</td><td>'; print '</td><td>';
print $form->editfieldval("NotePrivate",'note',$object->note_private,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); print $form->editfieldval("NotePrivate",'note',$object->note_private,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180');
print "</td></tr>"; print "</td></tr>";
} }

View File

@@ -219,8 +219,8 @@ print '<table class="border" width="100%">';
print '<tr><td valign="top" width="20%">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>'; print '<tr><td valign="top" width="20%">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
// Date payment // Date payment
print '<tr><td valign="top">'.$form->editfieldkey("Date",'date',$paiement->date,'id',$paiement->id,$user->rights->facture->paiement).'</td><td colspan="3">'; print '<tr><td valign="top">'.$form->editfieldkey("Date",'date',$paiement->date,$paiement,$user->rights->facture->paiement).'</td><td colspan="3">';
print $form->editfieldval("Date",'date',$paiement->date,'id',$paiement->id,$user->rights->facture->paiement,'day'); print $form->editfieldval("Date",'date',$paiement->date,$paiement,$user->rights->facture->paiement,'day');
print '</td></tr>'; print '</td></tr>';
// Payment type (VIR, LIQ, ...) // Payment type (VIR, LIQ, ...)
@@ -228,16 +228,16 @@ $labeltype=$langs->trans("PaymentType".$paiement->type_code)!=("PaymentType".$pa
print '<tr><td valign="top">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>'; print '<tr><td valign="top">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
// Payment numero // Payment numero
print '<tr><td valign="top">'.$form->editfieldkey("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">'; print '<tr><td valign="top">'.$form->editfieldkey("Numero",'num',$paiement->numero,$paiement,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string'); print $form->editfieldval("Numero",'num',$paiement->numero,$paiement,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string');
print '</td></tr>'; print '</td></tr>';
// Amount // Amount
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Note // Note
print '<tr><td valign="top">'.$form->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement).'</td><td colspan="3">'; print '<tr><td valign="top">'.$form->editfieldkey("Note",'note',$paiement->note,$paiement,$user->rights->facture->paiement).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement,'text'); print $form->editfieldval("Note",'note',$paiement->note,$paiement,$user->rights->facture->paiement,'text');
print '</td></tr>'; print '</td></tr>';
// Bank account // Bank account

View File

@@ -66,8 +66,18 @@ if((isset($_GET['field']) && ! empty($_GET['field']))
$cachename = 'cache_'.GETPOST('method'); $cachename = 'cache_'.GETPOST('method');
$form = new Form($db); $form = new Form($db);
$ret = $form->$methodname(); if (method_exists($form, $methodname))
if ($ret > 0) echo json_encode($form->$cachename); {
$ret = $form->$methodname();
if ($ret > 0) echo json_encode($form->$cachename);
}
else
{
dol_include_once('/'.$element.'/class/'.$element.'.class.php');
$classname = ucfirst($element);
$object = new $classname($db);
print_r($object);
}
} }
else else
{ {

View File

@@ -68,16 +68,15 @@ class Form
/** /**
* Output key field for an editable field * Output key field for an editable field
* *
* @param string $text Text of label or key to translate * @param string $text Text of label or key to translate
* @param string $htmlname Name of select field * @param string $htmlname Name of select field
* @param string $preselected Value to show/edit * @param string $preselected Name of Value to show/edit (not used in this function)
* @param string $paramkey Key of parameter for Url (unique if there is several parameter to show). In most cases "id". * @param object $object Object
* @param string $paramvalue Value of parameter for Url * @param boolean $perm Permission to allow button to edit parameter
* @param boolean $perm Permission to allow button to edit parameter
* @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...)
* @return string HTML edit field * @return string HTML edit field
*/ */
function editfieldkey($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string') function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string')
{ {
global $conf,$langs; global $conf,$langs;
@@ -102,7 +101,7 @@ class Form
$ret.='<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">'; $ret.='<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">';
$ret.=$langs->trans($text); $ret.=$langs->trans($text);
$ret.='</td>'; $ret.='</td>';
if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&amp;'.$paramkey.'='.$paramvalue.'">'.img_edit($langs->trans('Edit'),1).'</a></td>'; if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&amp;id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
$ret.='</tr></table>'; $ret.='</tr></table>';
} }
@@ -115,13 +114,13 @@ class Form
* @param string $text Text of label (not used in this function) * @param string $text Text of label (not used in this function)
* @param string $htmlname Name of select field * @param string $htmlname Name of select field
* @param string $value Value to show/edit * @param string $value Value to show/edit
* @param string $paramkey Key of parameter (unique if there is several parameter to show). In most cases "id". * @param object $object Object
* @param boolean $perm Permission to allow button to edit parameter * @param boolean $perm Permission to allow button to edit parameter
* @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...)
* @param string $editvalue When in edit mode, use this value as $value instead of value * @param string $editvalue When in edit mode, use this value as $value instead of value
* @return string HTML edit field * @return string HTML edit field
*/ */
function editfieldval($text,$htmlname,$value,$paramkey,$paramvalue,$perm,$typeofdata='string',$editvalue='') function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='')
{ {
global $conf,$langs,$db; global $conf,$langs,$db;
$ret=''; $ret='';
@@ -129,7 +128,7 @@ class Form
// When option to edit inline is activated // When option to edit inline is activated
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE))
{ {
$ret.=$this->editInPlace($value, $htmlname, $perm, $typeofdata); $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata);
} }
else else
{ {
@@ -139,7 +138,7 @@ class Form
$ret.='<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; $ret.='<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
$ret.='<input type="hidden" name="action" value="set'.$htmlname.'">'; $ret.='<input type="hidden" name="action" value="set'.$htmlname.'">';
$ret.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $ret.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$ret.='<input type="hidden" name="'.$paramkey.'" value="'.$paramvalue.'">'; $ret.='<input type="hidden" name="id" value="'.$object->id.'">';
$ret.='<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; $ret.='<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
$ret.='<tr><td>'; $ret.='<tr><td>';
if (preg_match('/^(string|email|numeric)/',$typeofdata)) if (preg_match('/^(string|email|numeric)/',$typeofdata))
@@ -153,7 +152,7 @@ class Form
} }
else if ($typeofdata == 'day' || $typeofdata == 'datepicker') else if ($typeofdata == 'day' || $typeofdata == 'datepicker')
{ {
$ret.=$this->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$value,$htmlname); $ret.=$this->form_date($_SERVER['PHP_SELF'].($objectkey?'?id='.$object->id:''),$value,$htmlname);
} }
else if (preg_match('/^ckeditor/',$typeofdata)) else if (preg_match('/^ckeditor/',$typeofdata))
{ {
@@ -189,13 +188,14 @@ class Form
/** /**
* Output edit in place form * Output edit in place form
* *
* @param object $object Object
* @param string $value Value to show/edit * @param string $value Value to show/edit
* @param string $htmlname DIV ID (field name) * @param string $htmlname DIV ID (field name)
* @param int $condition Condition to edit * @param int $condition Condition to edit
* @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx') * @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx')
* @return string HTML edit in place * @return string HTML edit in place
*/ */
private function editInPlace($value, $htmlname, $condition, $inputType='textarea') private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea')
{ {
global $conf; global $conf;
@@ -206,7 +206,7 @@ class Form
else if (preg_match('/^numeric/',$inputType)) $value = price($value); else if (preg_match('/^numeric/',$inputType)) $value = price($value);
else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day');
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition) if ($condition)
{ {
if (preg_match('/^(string|email|numeric)/',$inputType)) if (preg_match('/^(string|email|numeric)/',$inputType))
{ {
@@ -215,13 +215,13 @@ class Form
} }
if ($inputType == 'datepicker') if ($inputType == 'datepicker')
{ {
$out.= '<input id="timeStamp" type="hidden"/>'; // Use for timestamp format $out.= '<input id="timestamp_'.$htmlname.'" type="hidden"/>'."\n"; // Use for timestamp format
} }
else if (preg_match('/^select/',$inputType)) else if (preg_match('/^select/',$inputType))
{ {
$tmp=explode(':',$inputType); $tmp=explode(':',$inputType);
$inputType=$tmp[0]; $inputOption=$tmp[1]; $inputType=$tmp[0]; $inputOption=$tmp[1];
$out.= '<input id="loadmethod" value="'.$inputOption.'" type="hidden"/>'; $out.= '<input id="loadmethod_'.$htmlname.'" value="'.$inputOption.'" type="hidden"/>'."\n";
} }
else if (preg_match('/^ckeditor/',$inputType)) else if (preg_match('/^ckeditor/',$inputType))
{ {
@@ -229,17 +229,19 @@ class Form
$inputType=$tmp[0]; $inputOption=$tmp[1]; $inputType=$tmp[0]; $inputOption=$tmp[1];
if (! empty($conf->fckeditor->enabled)) if (! empty($conf->fckeditor->enabled))
{ {
$out.= '<input id="toolbar" value="'.$inputOption.'" type="hidden"/>'; $out.= '<input id="ckeditor_toolbar" value="'.$inputOption.'" type="hidden"/>'."\n";
} }
else else
{ {
$inputType = 'textarea'; $inputType = 'textarea';
} }
} }
$out.= '<div class="editval_'.$inputType.'" id="val_'.$htmlname.'">'; $out.= '<input id="element_'.$htmlname.'" value="'.$object->element.'" type="hidden">'."\n";
$out.= $value; $out.= '<input id="table_element_'.$htmlname.'" value="'.$object->table_element.'" type="hidden">'."\n";
$out.= '</div>'."\n"; $out.= '<input id="fk_element_'.$htmlname.'" value="'.$object->id.'" type="hidden">'."\n";
$out.= '<div id="val_'.$htmlname.'" class="editval_'.$inputType.'">'.$value.'</div>'."\n";
} }
else else
{ {

View File

@@ -16,22 +16,18 @@ $(document).ready(function() {
rows : 4, rows : 4,
id : 'field', id : 'field',
tooltip : tooltipInPlace, tooltip : tooltipInPlace,
placeholder : placeholderInPlace, placeholder : '&nbsp;',
cancel : cancelInPlace, cancel : cancelInPlace,
submit : submitInPlace, submit : submitInPlace,
indicator : indicatorInPlace, indicator : indicatorInPlace,
loadurl : urlLoadInPlace, loadurl : urlLoadInPlace,
loaddata : { loaddata : function(result, settings) {
type: 'textarea', var htmlname = $(this).attr('id').substr(4);
element: element, return getParameters('textarea', htmlname);
table_element: table_element,
fk_element: fk_element
}, },
submitdata : { submitdata : function(result, settings) {
type: 'textarea', var htmlname = $(this).attr('id').substr(4);
element: element, return getParameters('textarea', htmlname);
table_element: table_element,
fk_element: fk_element
}, },
callback : function(result, settings) { callback : function(result, settings) {
var obj = $.parseJSON(result); var obj = $.parseJSON(result);
@@ -61,19 +57,17 @@ $(document).ready(function() {
id : 'field', id : 'field',
onblur : 'ignore', onblur : 'ignore',
tooltip : tooltipInPlace, tooltip : tooltipInPlace,
placeholder : placeholderInPlace, placeholder : '&nbsp;',
cancel : cancelInPlace, cancel : cancelInPlace,
submit : submitInPlace, submit : submitInPlace,
indicator : indicatorInPlace, indicator : indicatorInPlace,
ckeditor : { ckeditor : {
customConfig: ckeditorConfig, customConfig: ckeditorConfig,
toolbar: $('#toolbar').val() toolbar: $('#ckeditor_toolbar').val()
}, },
submitdata : { submitdata : function(result, settings) {
type: 'ckeditor', var htmlname = $(this).attr('id').substr(4);
element: element, return getParameters('ckeditor', htmlname);
table_element: table_element,
fk_element: fk_element
}, },
callback : function(result, settings) { callback : function(result, settings) {
var obj = $.parseJSON(result); var obj = $.parseJSON(result);
@@ -107,11 +101,9 @@ $(document).ready(function() {
cancel : cancelInPlace, cancel : cancelInPlace,
submit : submitInPlace, submit : submitInPlace,
indicator : indicatorInPlace, indicator : indicatorInPlace,
submitdata : { submitdata : function(result, settings) {
type: 'text', var htmlname = $(this).attr('id').substr(4);
element: element, return getParameters('text', htmlname);
table_element: table_element,
fk_element: fk_element
}, },
callback : function(result, settings) { callback : function(result, settings) {
var obj = $.parseJSON(result); var obj = $.parseJSON(result);
@@ -145,11 +137,9 @@ $(document).ready(function() {
cancel : cancelInPlace, cancel : cancelInPlace,
submit : submitInPlace, submit : submitInPlace,
indicator : indicatorInPlace, indicator : indicatorInPlace,
submitdata : { submitdata : function(result, settings) {
type: 'numeric', var htmlname = $(this).attr('id').substr(4);
element: element, return getParameters('numeric', htmlname);
table_element: table_element,
fk_element: fk_element
}, },
callback : function(result, settings) { callback : function(result, settings) {
var obj = $.parseJSON(result); var obj = $.parseJSON(result);
@@ -183,14 +173,9 @@ $(document).ready(function() {
cancel : cancelInPlace, cancel : cancelInPlace,
submit : submitInPlace, submit : submitInPlace,
indicator : indicatorInPlace, indicator : indicatorInPlace,
submitdata : function(value, settings) { submitdata : function(result, settings) {
return { var htmlname = $(this).attr('id').substr(4);
type: 'datepicker', return getParameters('datepicker', htmlname);
element: element,
table_element: table_element,
fk_element: fk_element,
timestamp: $('#timeStamp').val()
};
}, },
callback : function(result, settings) { callback : function(result, settings) {
var obj = $.parseJSON(result); var obj = $.parseJSON(result);
@@ -226,19 +211,13 @@ $(document).ready(function() {
submit : submitInPlace, submit : submitInPlace,
indicator : indicatorInPlace, indicator : indicatorInPlace,
loadurl : urlLoadInPlace, loadurl : urlLoadInPlace,
loaddata : { loaddata : function(result, settings) {
type: 'select', var htmlname = $(this).attr('id').substr(4);
method: $('#loadmethod').val(), return getParameters('select', htmlname);
element: element,
table_element: table_element,
fk_element: fk_element
}, },
submitdata : { submitdata : function(result, settings) {
type: 'select', var htmlname = $(this).attr('id').substr(4);
method: $('#loadmethod').val(), return getParameters('select', htmlname);
element: element,
table_element: table_element,
fk_element: fk_element
}, },
callback : function(result, settings) { callback : function(result, settings) {
var obj = $.parseJSON(result); var obj = $.parseJSON(result);
@@ -263,6 +242,29 @@ $(document).ready(function() {
$( '#val_' + $(this).attr('id') ).click(); $( '#val_' + $(this).attr('id') ).click();
}); });
function getParameters(type, htmlname) {
var element = $( '#element_' + htmlname ).val();
var table_element = $( '#table_element_' + htmlname ).val();
var fk_element = $( '#fk_element_' + htmlname ).val();
var method = false;
var timestamp = false;
if (type == 'select') {
var method = $( '#loadmethod_' + htmlname ).val();
} else if (type == 'datepicker') {
var timestamp = $('#timestamp_' + htmlname ).val();
}
return {
type: type,
element: element,
table_element: table_element,
fk_element: fk_element,
method: method,
timestamp: timestamp
};
}
$('.edit_autocomplete').editable(urlSaveInPlace, { $('.edit_autocomplete').editable(urlSaveInPlace, {
type : 'autocomplete', type : 'autocomplete',
id : 'field', id : 'field',

View File

@@ -689,14 +689,6 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
if (! $notab) $out.="\n".'<div class="tabBar">'."\n"; if (! $notab) $out.="\n".'<div class="tabBar">'."\n";
// Parameters for edit in place
if (! empty($GLOBALS['object']))
{
$out.='<div id="jeditable_element" class="hidden">'.$GLOBALS['object']->element.'</div>'."\n";
$out.='<div id="jeditable_table_element" class="hidden">'.$GLOBALS['object']->table_element.'</div>'."\n";
$out.='<div id="jeditable_fk_element" class="hidden">'.$GLOBALS['object']->id.'</div>'."\n";
}
return $out; return $out;
} }

View File

@@ -1016,8 +1016,8 @@ else
} }
// Weight // Weight
print '<tr><td>'.$form->editfieldkey("Weight",'trueWeight',$object->trueWeight,'id',$object->id,$user->rights->expedition->creer).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
print $form->editfieldval("Weight",'trueWeight',$object->trueWeight,'id',$object->id,$user->rights->expedition->creer); print $form->editfieldval("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer);
print $object->weight_units?measuring_units_string($object->weight_units,"weight"):''; print $object->weight_units?measuring_units_string($object->weight_units,"weight"):'';
print '</td></tr>'; print '</td></tr>';
@@ -1044,20 +1044,20 @@ else
print '</tr>'; print '</tr>';
// Width // Width
print '<tr><td>'.$form->editfieldkey("Width",'trueWidth',$object->trueWidth,'id',$object->id,$user->rights->expedition->creer).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
print $form->editfieldval("Width",'trueWidth',$object->trueWidth,'id',$object->id,$user->rights->expedition->creer); print $form->editfieldval("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer);
print $object->trueWidth?measuring_units_string($object->width_units,"size"):''; print $object->trueWidth?measuring_units_string($object->width_units,"size"):'';
print '</td></tr>'; print '</td></tr>';
// Height // Height
print '<tr><td>'.$form->editfieldkey("Height",'trueHeight',$object->trueHeight,'id',$object->id,$user->rights->expedition->creer).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
print $form->editfieldval("Height",'trueHeight',$object->trueHeight,'id',$object->id,$user->rights->expedition->creer); print $form->editfieldval("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer);
print $object->trueHeight?measuring_units_string($object->height_units,"size"):''; print $object->trueHeight?measuring_units_string($object->height_units,"size"):'';
print '</td></tr>'; print '</td></tr>';
// Depth // Depth
print '<tr><td>'.$form->editfieldkey("Depth",'trueDepth',$object->trueDepth,'id',$object->id,$user->rights->expedition->creer).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
print $form->editfieldval("Depth",'trueDepth',$object->trueDepth,'id',$object->id,$user->rights->expedition->creer); print $form->editfieldval("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer);
print $object->trueDepth?measuring_units_string($object->depth_units,"size"):''; print $object->trueDepth?measuring_units_string($object->depth_units,"size"):'';
print '</td></tr>'; print '</td></tr>';
@@ -1098,8 +1098,8 @@ else
print '</tr>'; print '</tr>';
// Tracking Number // Tracking Number
print '<tr><td>'.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,'id',$object->id,$user->rights->expedition->creer).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,'id',$object->id,$user->rights->expedition->creer,'string',$object->tracking_number); print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number);
print '</td></tr>'; print '</td></tr>';
print "</table>\n"; print "</table>\n";

View File

@@ -816,9 +816,9 @@ else if ($id > 0 || ! empty($ref))
// Description (must be a textarea and not html must be allowed (used in list view) // Description (must be a textarea and not html must be allowed (used in list view)
print '<tr><td valign="top">'; print '<tr><td valign="top">';
print $form->editfieldkey("Description",'description',$object->description,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); print $form->editfieldkey("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea');
print '</td><td colspan="3">'; print '</td><td colspan="3">';
print $form->editfieldval("Description",'description',$object->description,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@@ -857,18 +857,18 @@ else if ($id > 0 || ! empty($ref))
// Public note // Public note
print '<tr><td valign="top">'; print '<tr><td valign="top">';
print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180'); print $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180');
print '</td><td colspan="3">'; print '</td><td colspan="3">';
print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180'); print $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180');
print "</td></tr>"; print "</td></tr>";
// Private note // Private note
if (! $user->societe_id) if (! $user->societe_id)
{ {
print '<tr><td valign="top">'; print '<tr><td valign="top">';
print $form->editfieldkey("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180'); print $form->editfieldkey("NotePrivate",'note_private',$object->note_private,$object,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180');
print '</td><td colspan="3">'; print '</td><td colspan="3">';
print $form->editfieldval("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180'); print $form->editfieldval("NotePrivate",'note_private',$object->note_private,$object,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180');
print "</td></tr>"; print "</td></tr>";
} }

View File

@@ -42,12 +42,13 @@ $langs->load('suppliers');
$langs->load('companies'); $langs->load('companies');
$mesg=''; $mesg='';
$facid=GETPOST("facid"); $id = (GETPOST("facid") ? GETPOST("facid") : GETPOST("id"));
$action=GETPOST("action"); $action = GETPOST("action");
$confirm = GETPOST("confirm");
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'fournisseur', $facid, 'facture_fourn', 'facture'); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
$object=new FactureFournisseur($db); $object=new FactureFournisseur($db);
@@ -58,7 +59,7 @@ $object=new FactureFournisseur($db);
*/ */
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $_REQUEST['confirm'] == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes')
{ {
if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
{ {
@@ -66,25 +67,24 @@ if ($action == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
} }
else else
{ {
$result=$object->createFromClone($facid); $result=$object->createFromClone($id);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
exit; exit;
} }
else else
{ {
$langs->load("errors"); $langs->load("errors");
$mesg='<div class="error">'.$langs->trans($object->error).'</div>'; $mesg='<div class="error">'.$langs->trans($object->error).'</div>';
$_GET['action']=''; $action='';
$_GET['id']=$_REQUEST['id'];
} }
} }
} }
if ($action == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider) if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider)
{ {
$object->fetch($facid); $object->fetch($id);
$result = $object->validate($user); $result = $object->validate($user);
if ($result < 0) if ($result < 0)
{ {
@@ -92,12 +92,12 @@ if ($action == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $user->rights
} }
} }
if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') if ($action == 'confirm_delete' && $confirm == 'yes')
{ {
if ($user->rights->fournisseur->facture->supprimer ) if ($user->rights->fournisseur->facture->supprimer )
{ {
$object->fetch($facid); $object->fetch($id);
$result=$object->delete($facid); $result=$object->delete($id);
if ($result > 0) if ($result > 0)
{ {
Header('Location: index.php'); Header('Location: index.php');
@@ -110,43 +110,41 @@ if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
} }
} }
if ($action == 'confirm_deleteproductline' && $_REQUEST['confirm'] == 'yes') if ($action == 'confirm_deleteproductline' && $confirm == 'yes')
{ {
if ($user->rights->fournisseur->facture->creer) if ($user->rights->fournisseur->facture->creer)
{ {
$object->fetch($facid); $object->fetch($id);
$object->deleteline($_REQUEST['lineid']); $object->deleteline($_REQUEST['lineid']);
$_GET['action'] = ''; $action = '';
} }
} }
if ($action == 'confirm_paid' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->facture->creer) if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($facid); $object->fetch($id);
$result=$object->set_paid($user); $result=$object->set_paid($user);
} }
// Set supplier ref // Set supplier ref
if (($action == 'setref_supplier' || $action == 'set_ref_supplier') && $user->rights->fournisseur->facture->creer) if (($action == 'setref_supplier' || $action == 'set_ref_supplier') && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($facid); $object->fetch($id);
$result=$object->set_ref_supplier($user, $_POST['ref_supplier']); $result=$object->set_ref_supplier($user, $_POST['ref_supplier']);
$_GET['facid']=$facid;
} }
// Set supplier ref // Set supplier ref
if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($facid); $object->fetch($id);
$object->label=$_POST['label']; $object->label=$_POST['label'];
$result=$object->update($user); $result=$object->update($user);
if ($result < 0) dol_print_error($db); if ($result < 0) dol_print_error($db);
$_GET['facid']=$facid;
} }
if ($action == 'setdate' && $user->rights->fournisseur->facture->creer) if ($action == 'setdate' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($facid); $object->fetch($id);
$object->date=dol_mktime(12,0,0,$_POST['datemonth'],$_POST['dateday'],$_POST['dateyear']); $object->date=dol_mktime(12,0,0,$_POST['datemonth'],$_POST['dateday'],$_POST['dateyear']);
if ($object->date_echeance < $object->date) $object->date_echeance=$object->date; if ($object->date_echeance < $object->date) $object->date_echeance=$object->date;
$result=$object->update($user); $result=$object->update($user);
@@ -154,7 +152,7 @@ if ($action == 'setdate' && $user->rights->fournisseur->facture->creer)
} }
if ($action == 'setdate_echeance' && $user->rights->fournisseur->facture->creer) if ($action == 'setdate_echeance' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($facid); $object->fetch($id);
$object->date_echeance=dol_mktime(12,0,0,$_POST['date_echeancemonth'],$_POST['date_echeanceday'],$_POST['date_echeanceyear']); $object->date_echeance=dol_mktime(12,0,0,$_POST['date_echeancemonth'],$_POST['date_echeanceday'],$_POST['date_echeanceyear']);
if ($object->date_echeance < $object->date) $object->date_echeance=$object->date; if ($object->date_echeance < $object->date) $object->date_echeance=$object->date;
$result=$object->update($user); $result=$object->update($user);
@@ -164,7 +162,7 @@ if ($action == 'setdate_echeance' && $user->rights->fournisseur->facture->creer)
// Delete payment // Delete payment
if($action == 'deletepaiement') if($action == 'deletepaiement')
{ {
$object->fetch($_GET['facid']); $object->fetch($id);
if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
{ {
$paiementfourn = new PaiementFourn($db); $paiementfourn = new PaiementFourn($db);
@@ -192,13 +190,14 @@ if ($action == 'update' && ! $_POST['cancel'])
if (! $error) if (! $error)
{ {
// TODO move to DAO class
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn set '; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn set ';
$sql .= " facnumber='".$db->escape(trim($_POST['facnumber']))."'"; $sql .= " facnumber='".$db->escape(trim($_POST['facnumber']))."'";
$sql .= ", libelle='".$db->escape(trim($_POST['libelle']))."'"; $sql .= ", libelle='".$db->escape(trim($_POST['libelle']))."'";
$sql .= ", note='".$db->escape($_POST['note'])."'"; $sql .= ", note='".$db->escape($_POST['note'])."'";
$sql .= ", datef = '".$db->idate($date)."'"; $sql .= ", datef = '".$db->idate($date)."'";
$sql .= ", date_lim_reglement = '".$db->idate($date_echeance)."'"; $sql .= ", date_lim_reglement = '".$db->idate($date_echeance)."'";
$sql .= ' WHERE rowid = '.$_GET['facid'].' ;'; $sql .= ' WHERE rowid = '.$id;
$result = $db->query($sql); $result = $db->query($sql);
} }
} }
@@ -259,10 +258,10 @@ if ($action == 'add' && $user->rights->fournisseur->facture->creer)
$object->origin = $_POST['origin']; $object->origin = $_POST['origin'];
$object->origin_id = $_POST['originid']; $object->origin_id = $_POST['originid'];
$facid = $object->create($user); $id = $object->create($user);
// Add lines // Add lines
if ($facid > 0) if ($id > 0)
{ {
require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'); require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement); $classname = ucfirst($subelement);
@@ -327,8 +326,8 @@ if ($action == 'add' && $user->rights->fournisseur->facture->creer)
// If some invoice's lines already known // If some invoice's lines already known
else else
{ {
$facid = $object->create($user); $id = $object->create($user);
if ($facid < 0) if ($id < 0)
{ {
$error++; $error++;
} }
@@ -376,7 +375,7 @@ if ($action == 'add' && $user->rights->fournisseur->facture->creer)
else else
{ {
$db->commit(); $db->commit();
header('Location: fiche.php?facid='.$facid); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit; exit;
} }
} }
@@ -384,7 +383,7 @@ if ($action == 'add' && $user->rights->fournisseur->facture->creer)
if ($action == 'del_ligne') if ($action == 'del_ligne')
{ {
$object->fetch($_GET['facid']); $object->fetch($id);
$object->deleteline($_GET['lineid']); $object->deleteline($_GET['lineid']);
$action = 'edit'; $action = 'edit';
} }
@@ -394,7 +393,7 @@ if ($action == 'update_line')
{ {
if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification
{ {
$object->fetch($_GET['facid']); $object->fetch($id);
if ($_POST['puht']) if ($_POST['puht'])
{ {
@@ -441,7 +440,7 @@ if ($action == 'update_line')
if ($action == 'addline') if ($action == 'addline')
{ {
$ret=$object->fetch($_GET['facid']); $ret=$object->fetch($id);
if ($ret < 0) if ($ret < 0)
{ {
dol_print_error($db,$object->error); dol_print_error($db,$object->error);
@@ -548,7 +547,7 @@ if ($action == 'addline')
if ($action == 'classin') if ($action == 'classin')
{ {
$object->fetch($_GET['facid']); $object->fetch($id);
$result=$object->setProject($_POST['projectid']); $result=$object->setProject($_POST['projectid']);
} }
@@ -556,9 +555,10 @@ if ($action == 'classin')
// Repasse la facture en mode brouillon // Repasse la facture en mode brouillon
if ($action == 'edit' && $user->rights->fournisseur->facture->creer) if ($action == 'edit' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($_GET['facid']); $object->fetch($id);
// On verifie si la facture a des paiements // On verifie si la facture a des paiements
// TODO move to DAO class
$sql = 'SELECT pf.amount'; $sql = 'SELECT pf.amount';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf';
$sql.= ' WHERE pf.fk_facturefourn = '.$object->id; $sql.= ' WHERE pf.fk_facturefourn = '.$object->id;
@@ -599,14 +599,14 @@ if ($action == 'edit' && $user->rights->fournisseur->facture->creer)
if ($action == 'reopen' && $user->rights->fournisseur->facture->creer) if ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
{ {
$result = $object->fetch($_GET['facid']); $result = $object->fetch($id);
if ($object->statut == 2 if ($object->statut == 2
|| ($object->statut == 3 && $object->close_code != 'replaced')) || ($object->statut == 3 && $object->close_code != 'replaced'))
{ {
$result = $object->set_unpaid($user); $result = $object->set_unpaid($user);
if ($result > 0) if ($result > 0)
{ {
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_GET['facid']); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit; exit;
} }
else else
@@ -655,7 +655,7 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
{ {
$langs->load('mails'); $langs->load('mails');
$object->fetch($_GET['facid']); $object->fetch($id);
$result=$object->fetch_thirdparty(); $result=$object->fetch_thirdparty();
if ($result > 0) if ($result > 0)
{ {
@@ -736,12 +736,12 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
$error=0; $error=0;
// Initialisation donnees // Initialisation donnees
$object->sendtoid = $sendtoid; $object->sendtoid = $sendtoid;
$object->actiontypecode = $actiontypecode; $object->actiontypecode = $actiontypecode;
$object->actionmsg = $actionmsg; $object->actionmsg = $actionmsg;
$object->actionmsg2 = $actionmsg2; $object->actionmsg2 = $actionmsg2;
$object->fk_element = $object->id; $object->fk_element = $object->id;
$object->elementtype = $object->element; $object->elementtype = $object->element;
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
@@ -758,7 +758,7 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
{ {
// Redirect here // Redirect here
// This avoid sending mail twice if going out and then back to page // This avoid sending mail twice if going out and then back to page
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&mesg='.urlencode($mesg)); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mesg='.urlencode($mesg));
exit; exit;
} }
} }
@@ -811,7 +811,7 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
if ($action == 'builddoc') if ($action == 'builddoc')
{ {
// Save modele used // Save modele used
$object->fetch($_REQUEST['facid']); $object->fetch($id);
if ($_REQUEST['model']) if ($_REQUEST['model'])
{ {
$object->setDocModel($user, $_REQUEST['model']); $object->setDocModel($user, $_REQUEST['model']);
@@ -823,7 +823,7 @@ if ($action == 'builddoc')
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
$result=supplier_invoice_pdf_create($db, $object,$object->modelpdf,$outputlangs); $result=supplier_invoice_pdf_create($db,$object,$object->modelpdf,$outputlangs);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$result); dol_print_error($db,$result);
@@ -831,7 +831,7 @@ if ($action == 'builddoc')
} }
else else
{ {
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
exit; exit;
} }
} }
@@ -1117,7 +1117,7 @@ if ($action == 'create')
} }
else else
{ {
if ($_GET['facid'] > 0) if ($id > 0)
{ {
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
@@ -1129,16 +1129,15 @@ else
$productstatic = new Product($db); $productstatic = new Product($db);
$fac = new FactureFournisseur($db); $object->fetch($id);
$fac->fetch($_GET['facid']);
$societe = new Fournisseur($db); $societe = new Fournisseur($db);
$societe->fetch($fac->socid); $societe->fetch($object->socid);
/* /*
* View card * View card
*/ */
$head = facturefourn_prepare_head($fac); $head = facturefourn_prepare_head($object);
$titre=$langs->trans('SupplierInvoice'); $titre=$langs->trans('SupplierInvoice');
dol_fiche_head($head, 'card', $titre, 0, 'bill'); dol_fiche_head($head, 'card', $titre, 0, 'bill');
@@ -1147,7 +1146,7 @@ else
// Confirmation de la suppression d'une ligne produit // Confirmation de la suppression d'une ligne produit
if ($action == 'confirm_delete_line') if ($action == 'confirm_delete_line')
{ {
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline', '', 1, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline', '', 1, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@@ -1160,21 +1159,21 @@ else
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
); );
// Paiement incomplet. On demande si motif = escompte ou autre // Paiement incomplet. On demande si motif = escompte ou autre
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$fac->ref),'confirm_clone',$formquestion,'yes', 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes', 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Confirmation de la validation // Confirmation de la validation
if ($action == 'valid') if ($action == 'valid')
{ {
$ret=$form->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $fac->ref), 'confirm_valid', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $object->ref), 'confirm_valid', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Confirmation set paid // Confirmation set paid
if ($action == 'paid') if ($action == 'paid')
{ {
$ret=$form->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $fac->ref), 'confirm_paid', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@@ -1183,7 +1182,7 @@ else
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@@ -1195,37 +1194,37 @@ else
// Ref // Ref
print '<tr><td nowrap="nowrap" width="20%">'.$langs->trans("Ref").'</td><td colspan="4">'; print '<tr><td nowrap="nowrap" width="20%">'.$langs->trans("Ref").'</td><td colspan="4">';
print $form->showrefnav($fac,'facid','',1,'rowid','ref',$morehtmlref); print $form->showrefnav($object,'id','',1,'rowid','ref',$morehtmlref);
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Ref supplier // Ref supplier
print '<tr><td>'.$form->editfieldkey("RefSupplier",'ref_supplier',$fac->ref_supplier,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="4">'; print '<tr><td>'.$form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="4">';
print $form->editfieldval("RefSupplier",'ref_supplier',$fac->ref_supplier,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)); print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer));
print '</td></tr>'; print '</td></tr>';
// Third party // Third party
print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="4">'.$societe->getNomUrl(1); print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="4">'.$societe->getNomUrl(1);
print ' &nbsp; (<a href="'.DOL_URL_ROOT.'/fourn/facture/index.php?socid='.$fac->socid.'">'.$langs->trans('OtherBills').'</a>)</td>'; print ' &nbsp; (<a href="'.DOL_URL_ROOT.'/fourn/facture/index.php?socid='.$object->socid.'">'.$langs->trans('OtherBills').'</a>)</td>';
print '</tr>'; print '</tr>';
// Type // Type
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="4">'; print '<tr><td>'.$langs->trans('Type').'</td><td colspan="4">';
print $fac->getLibType(); print $object->getLibType();
if ($fac->type == 1) if ($object->type == 1)
{ {
$facreplaced=new FactureFournisseur($db); $facreplaced=new FactureFournisseur($db);
$facreplaced->fetch($fac->fk_facture_source); $facreplaced->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')';
} }
if ($fac->type == 2) if ($object->type == 2)
{ {
$facusing=new FactureFournisseur($db); $facusing=new FactureFournisseur($db);
$facusing->fetch($fac->fk_facture_source); $facusing->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')'; print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
} }
$facidavoir=$fac->getListIdAvoirFromInvoice(); $facidavoir=$object->getListIdAvoirFromInvoice();
if (count($facidavoir) > 0) if (count($facidavoir) > 0)
{ {
print ' ('.$langs->transnoentities("InvoiceHasAvoir"); print ' ('.$langs->transnoentities("InvoiceHasAvoir");
@@ -1250,8 +1249,8 @@ else
// Label // Label
print '<tr><td>'.$form->editfieldkey("Label",'label',$fac->label,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="3">';
print $form->editfieldval("Label",'label',$fac->label,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)); print $form->editfieldval("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer));
print '</td>'; print '</td>';
/* /*
@@ -1268,12 +1267,14 @@ else
} }
print '<td rowspan="'.$nbrows.'" valign="top">'; print '<td rowspan="'.$nbrows.'" valign="top">';
// TODO move to DAO class
$sql = 'SELECT datep as dp, pf.amount,'; $sql = 'SELECT datep as dp, pf.amount,';
$sql .= ' c.libelle as paiement_type, p.num_paiement, p.rowid'; $sql .= ' c.libelle as paiement_type, p.num_paiement, p.rowid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
$sql .= ' WHERE pf.fk_facturefourn = '.$fac->id; $sql .= ' WHERE pf.fk_facturefourn = '.$object->id;
$sql .= ' ORDER BY dp DESC'; $sql .= ' ORDER BY dp DESC';
$result = $db->query($sql); $result = $db->query($sql);
@@ -1299,9 +1300,9 @@ else
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>'; print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>';
print '<td align="right">'.price($objp->amount).'</td>'; print '<td align="right">'.price($objp->amount).'</td>';
print '<td align="center">'; print '<td align="center">';
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
{ {
print '<a href="fiche.php?facid='.$fac->id.'&amp;action=deletepaiement&amp;paiement_id='.$objp->rowid.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=deletepaiement&amp;paiement_id='.$objp->rowid.'">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';
} }
@@ -1311,12 +1312,12 @@ else
$i++; $i++;
} }
if ($fac->paye == 0) if ($object->paye == 0)
{ {
print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPaid').' :</td><td align="right"><b>'.price($totalpaye).'</b></td></tr>'; print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPaid').' :</td><td align="right"><b>'.price($totalpaye).'</b></td></tr>';
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td></tr>'; print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($object->total_ttc).'</td></tr>';
$resteapayer = $fac->total_ttc - $totalpaye; $resteapayer = $object->total_ttc - $totalpaye;
print '<tr><td colspan="2" align="right">'.$langs->trans('RemainderToPay').' :</td>'; print '<tr><td colspan="2" align="right">'.$langs->trans('RemainderToPay').' :</td>';
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayer).'</b></td></tr>'; print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayer).'</b></td></tr>';
@@ -1333,21 +1334,21 @@ else
print '</tr>'; print '</tr>';
// Date // Date
print '<tr><td>'.$form->editfieldkey("Date",'date',$fac->datep,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer && $fac->getSommePaiement() <= 0)).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Date",'date',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0)).'</td><td colspan="3">';
print $form->editfieldval("Date",'date',$fac->datep,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer && $fac->getSommePaiement() <= 0),'day'); print $form->editfieldval("Date",'date',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'day');
print '</td>'; print '</td>';
// Due date // Due date
print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_echeance',$fac->date_echeance,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer && $fac->getSommePaiement() <= 0)).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_echeance',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0)).'</td><td colspan="3">';
print $form->editfieldval("DateMaxPayment",'date_echeance',$fac->date_echeance,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer && $fac->getSommePaiement() <= 0),'day'); print $form->editfieldval("DateMaxPayment",'date_echeance',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'day');
print '</td>'; print '</td>';
// Status // Status
$alreadypaid=$fac->getSommePaiement(); $alreadypaid=$object->getSommePaiement();
print '<tr><td>'.$langs->trans('Status').'</td><td colspan="3">'.$fac->getLibStatut(4,$alreadypaid).'</td></tr>'; print '<tr><td>'.$langs->trans('Status').'</td><td colspan="3">'.$object->getLibStatut(4,$alreadypaid).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountHT').'</td><td align="right">'.price($fac->total_ht).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountHT').'</td><td align="right">'.price($object->total_ht).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right">'.price($fac->total_tva).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right">'.price($object->total_tva).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Amount Local Taxes // Amount Local Taxes
if ($mysoc->pays_code=='ES') if ($mysoc->pays_code=='ES')
@@ -1355,17 +1356,17 @@ else
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{ {
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td>'; print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td>';
print '<td align="right">'.price($fac->total_localtax1).'</td>'; print '<td align="right">'.price($object->total_localtax1).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
} }
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{ {
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td>'; print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td>';
print '<td align="right">'.price($fac->total_localtax2).'</td>'; print '<td align="right">'.price($object->total_localtax2).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
} }
} }
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($fac->total_ttc).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($object->total_ttc).'</td><td colspan="2" align="left">'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Project // Project
if ($conf->projet->enabled) if ($conf->projet->enabled)
@@ -1379,7 +1380,7 @@ else
print '</td>'; print '</td>';
if ($action != 'classify') if ($action != 'classify')
{ {
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&amp;facid='.$fac->id.'">'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&amp;id='.$object->id.'">';
print img_edit($langs->trans('SetProject'),1); print img_edit($langs->trans('SetProject'),1);
print '</a></td>'; print '</a></td>';
} }
@@ -1388,11 +1389,11 @@ else
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'classify') if ($action == 'classify')
{ {
$form->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->fk_project,'projectid'); $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,'projectid');
} }
else else
{ {
$form->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->fk_project,'none'); $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,'none');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@@ -1407,7 +1408,7 @@ else
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
$var=1; $var=1;
$num=count($fac->lines); $num=count($object->lines);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
if ($i == 0) if ($i == 0)
@@ -1425,29 +1426,29 @@ else
} }
// Show product and description // Show product and description
$type=$fac->lines[$i]->product_type?$fac->lines[$i]->product_type:$fac->lines[$i]->fk_product_type; $type=$object->lines[$i]->product_type?$object->lines[$i]->product_type:$object->lines[$i]->fk_product_type;
// Try to enhance type detection using date_start and date_end for free lines where type // Try to enhance type detection using date_start and date_end for free lines where type
// was not saved. // was not saved.
if (! empty($fac->lines[$i]->date_start)) $type=1; if (! empty($object->lines[$i]->date_start)) $type=1;
if (! empty($fac->lines[$i]->date_end)) $type=1; if (! empty($object->lines[$i]->date_end)) $type=1;
$var=!$var; $var=!$var;
// Edit line // Edit line
if ($fac->statut == 0 && $action == 'mod_ligne' && $_GET['etat'] == '0' && $_GET['lineid'] == $fac->lines[$i]->rowid) if ($object->statut == 0 && $action == 'mod_ligne' && $_GET['etat'] == '0' && $_GET['lineid'] == $object->lines[$i]->rowid)
{ {
print '<form action="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;etat=1&amp;lineid='.$fac->lines[$i]->rowid.'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;etat=1&amp;lineid='.$object->lines[$i]->rowid.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_line">'; print '<input type="hidden" name="action" value="update_line">';
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
// Show product and description // Show product and description
print '<td>'; print '<td>';
if (($conf->product->enabled || $conf->service->enabled) && $fac->lines[$i]->fk_product) if (($conf->product->enabled || $conf->service->enabled) && $object->lines[$i]->fk_product)
{ {
print '<input type="hidden" name="idprod" value="'.$fac->lines[$i]->fk_product.'">'; print '<input type="hidden" name="idprod" value="'.$object->lines[$i]->fk_product.'">';
$product_static=new ProductFournisseur($db); $product_static=new ProductFournisseur($db);
$product_static->fetch($fac->lines[$i]->fk_product); $product_static->fetch($object->lines[$i]->fk_product);
$text=$product_static->getNomUrl(1); $text=$product_static->getNomUrl(1);
$text.= ' - '.$product_static->libelle; $text.= ' - '.$product_static->libelle;
print $text; print $text;
@@ -1455,7 +1456,7 @@ else
} }
else else
{ {
print $form->select_type_of_lines($fac->lines[$i]->product_type,'type',1); print $form->select_type_of_lines($object->lines[$i]->product_type,'type',1);
if ($conf->product->enabled && $conf->service->enabled) print '<br>'; if ($conf->product->enabled && $conf->service->enabled) print '<br>';
} }
@@ -1463,21 +1464,21 @@ else
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
$nbrows=ROWS_2; $nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$doleditor=new DolEditor('label',$fac->lines[$i]->description,'',128,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); $doleditor=new DolEditor('label',$object->lines[$i]->description,'',128,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create(); $doleditor->Create();
print '</td>'; print '</td>';
// VAT // VAT
print '<td align="right">'; print '<td align="right">';
print $form->load_tva('tauxtva',$fac->lines[$i]->tva_tx,$societe,$mysoc); print $form->load_tva('tauxtva',$object->lines[$i]->tva_tx,$societe,$mysoc);
print '</td>'; print '</td>';
// Unit price // Unit price
print '<td align="right" nowrap="nowrap"><input size="4" name="puht" type="text" value="'.price($fac->lines[$i]->pu_ht).'"></td>'; print '<td align="right" nowrap="nowrap"><input size="4" name="puht" type="text" value="'.price($object->lines[$i]->pu_ht).'"></td>';
print '<td align="right" nowrap="nowrap"><input size="4" name="puttc" type="text" value=""></td>'; print '<td align="right" nowrap="nowrap"><input size="4" name="puttc" type="text" value=""></td>';
print '<td align="right"><input size="1" name="qty" type="text" value="'.$fac->lines[$i]->qty.'"></td>'; print '<td align="right"><input size="1" name="qty" type="text" value="'.$object->lines[$i]->qty.'"></td>';
print '<td align="right" nowrap="nowrap">&nbsp;</td>'; print '<td align="right" nowrap="nowrap">&nbsp;</td>';
@@ -1495,57 +1496,57 @@ else
// Show product and description // Show product and description
print '<td>'; print '<td>';
if ($fac->lines[$i]->fk_product) if ($object->lines[$i]->fk_product)
{ {
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
$product_static=new ProductFournisseur($db); $product_static=new ProductFournisseur($db);
$product_static->fetch($fac->lines[$i]->fk_product); $product_static->fetch($object->lines[$i]->fk_product);
$text=$product_static->getNomUrl(1); $text=$product_static->getNomUrl(1);
$text.= ' - '.$product_static->libelle; $text.= ' - '.$product_static->libelle;
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($fac->lines[$i]->description)); $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($object->lines[$i]->description));
print $form->textwithtooltip($text,$description,3,'','',$i); print $form->textwithtooltip($text,$description,3,'','',$i);
// Show range // Show range
print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end); print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
// Add description in form // Add description in form
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($fac->lines[$i]->description && $fac->lines[$i]->description!=$product_static->libelle)?'<br>'.dol_htmlentitiesbr($fac->lines[$i]->description):''; if ($conf->global->PRODUIT_DESC_IN_FORM) print ($object->lines[$i]->description && $object->lines[$i]->description!=$product_static->libelle)?'<br>'.dol_htmlentitiesbr($object->lines[$i]->description):'';
} }
// Description - Editor wysiwyg // Description - Editor wysiwyg
if (! $fac->lines[$i]->fk_product) if (! $object->lines[$i]->fk_product)
{ {
if ($type==1) $text = img_object($langs->trans('Service'),'service'); if ($type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product'); else $text = img_object($langs->trans('Product'),'product');
print $text.' '.nl2br($fac->lines[$i]->description); print $text.' '.nl2br($object->lines[$i]->description);
// Show range // Show range
print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end); print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
} }
print '</td>'; print '</td>';
// VAT // VAT
print '<td align="right">'.vatrate($fac->lines[$i]->tva_tx).'%</td>'; print '<td align="right">'.vatrate($object->lines[$i]->tva_tx).'%</td>';
// Unit price // Unit price
print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->pu_ht,'MU').'</td>'; print '<td align="right" nowrap="nowrap">'.price($object->lines[$i]->pu_ht,'MU').'</td>';
print '<td align="right" nowrap="nowrap">'.($fac->lines[$i]->pu_ttc?price($fac->lines[$i]->pu_ttc,'MU'):'&nbsp;').'</td>'; print '<td align="right" nowrap="nowrap">'.($object->lines[$i]->pu_ttc?price($object->lines[$i]->pu_ttc,'MU'):'&nbsp;').'</td>';
print '<td align="right">'.$fac->lines[$i]->qty.'</td>'; print '<td align="right">'.$object->lines[$i]->qty.'</td>';
print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->total_ht).'</td>'; print '<td align="right" nowrap="nowrap">'.price($object->lines[$i]->total_ht).'</td>';
print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->total_ttc).'</td>'; print '<td align="right" nowrap="nowrap">'.price($object->lines[$i]->total_ttc).'</td>';
print '<td align="center" width="16">'; print '<td align="center" width="16">';
if ($fac->statut == 0) print '<a href="fiche.php?facid='.$fac->id.'&amp;action=mod_ligne&amp;etat=0&amp;lineid='.$fac->lines[$i]->rowid.'">'.img_edit().'</a>'; if ($object->statut == 0) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=mod_ligne&amp;etat=0&amp;lineid='.$object->lines[$i]->rowid.'">'.img_edit().'</a>';
else print '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
print '<td align="center" width="16">'; print '<td align="center" width="16">';
if ($fac->statut == 0) print '<a href="fiche.php?facid='.$fac->id.'&amp;action=confirm_delete_line&amp;lineid='.$fac->lines[$i]->rowid.'">'.img_delete().'</a>'; if ($object->statut == 0) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=confirm_delete_line&amp;lineid='.$object->lines[$i]->rowid.'">'.img_delete().'</a>';
else print '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
@@ -1558,7 +1559,7 @@ else
* Form to add new line * Form to add new line
*/ */
if ($fac->statut == 0 && $action != 'mod_ligne') if ($object->statut == 0 && $action != 'mod_ligne')
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'; print '<td>';
@@ -1575,9 +1576,9 @@ else
print '</tr>'; print '</tr>';
// Add free products/services form // Add free products/services form
print '<form action="fiche.php?facid='.$fac->id.'&amp;action=addline" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addline" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">'; print '<input type="hidden" name="facid" value="'.$object->id.'">';
print '<input type="hidden" name="socid" value="'.$societe->id.'">'; print '<input type="hidden" name="socid" value="'.$societe->id.'">';
$var=true; $var=true;
@@ -1634,15 +1635,14 @@ else
print '<td colspan="4">&nbsp;</td>'; print '<td colspan="4">&nbsp;</td>';
print '</tr>'; print '</tr>';
print '<form name="addline_predef" action="fiche.php?facid='.$fac->id.'&amp;action=addline" method="post">'; print '<form name="addline_predef" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addline" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="socid" value="'. $fac->socid .'">'; print '<input type="hidden" name="socid" value="'. $object->socid .'">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">'; print '<input type="hidden" name="facid" value="'.$object->id.'">';
print '<input type="hidden" name="socid" value="'.$fac->socid.'">';
$var=! $var; $var=! $var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td colspan="4">'; print '<td colspan="4">';
$form->select_produits_fournisseurs($fac->socid,'','idprodfournprice','',$filtre); $form->select_produits_fournisseurs($object->socid,'','idprodfournprice','',$filtre);
print '</td>'; print '</td>';
print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>'; print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
@@ -1667,11 +1667,11 @@ else
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// Reopen a standard paid invoice // Reopen a standard paid invoice
if (($fac->type == 0 || $fac->type == 1) && ($fac->statut == 2 || $fac->statut == 3)) // A paid invoice (partially or completely) if (($object->type == 0 || $object->type == 1) && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely)
{ {
if (! $facidnext && $fac->close_code != 'replaced') // Not replaced by another invoice if (! $facidnext && $object->close_code != 'replaced') // Not replaced by another invoice
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=reopen">'.$langs->trans('ReOpen').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans('ReOpen').'</a>';
} }
else else
{ {
@@ -1680,39 +1680,39 @@ else
} }
// Send by mail // Send by mail
if (($fac->statut == 1 || $fac->statut == 2)) if (($object->statut == 1 || $object->statut == 2))
{ {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send) if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
} }
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>'; else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
} }
//Make payments //Make payments
if ($action != 'edit' && $fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
{ {
print '<a class="butAction" href="paiement.php?facid='.$fac->id.'&amp;action=create">'.$langs->trans('DoPayment').'</a>'; print '<a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create">'.$langs->trans('DoPayment').'</a>';
} }
//Classify paid //Classify paid
if ($action != 'edit' && $fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=paid"'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid"';
print '>'.$langs->trans('ClassifyPaid').'</a>'; print '>'.$langs->trans('ClassifyPaid').'</a>';
//print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&amp;action=paid">'.$langs->trans('ClassifyPaid').'</a>'; //print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=paid">'.$langs->trans('ClassifyPaid').'</a>';
} }
//Validate //Validate
if ($action != 'edit' && $fac->statut == 0) if ($action != 'edit' && $object->statut == 0)
{ {
if (count($fac->lines)) if (count($object->lines))
{ {
if ($user->rights->fournisseur->facture->valider) if ($user->rights->fournisseur->facture->valider)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=valid"'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"';
print '>'.$langs->trans('Validate').'</a>'; print '>'.$langs->trans('Validate').'</a>';
} }
else else
@@ -1726,13 +1726,13 @@ else
//Clone //Clone
if ($action != 'edit' && $user->rights->fournisseur->facture->creer) if ($action != 'edit' && $user->rights->fournisseur->facture->creer)
{ {
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&amp;action=clone&amp;socid='.$fac->socid.'">'.$langs->trans('ToClone').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=clone&amp;socid='.$object->socid.'">'.$langs->trans('ToClone').'</a>';
} }
//Delete //Delete
if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer)
{ {
print '<a class="butActionDelete" href="fiche.php?facid='.$fac->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
} }
print '</div>'; print '</div>';
@@ -1745,15 +1745,15 @@ else
* Documents generes * Documents generes
*/ */
$ref=dol_sanitizeFileName($fac->ref); $ref=dol_sanitizeFileName($object->ref);
$subdir = get_exdir($fac->id,2).$ref; $subdir = get_exdir($object->id,2).$ref;
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($fac->id,2).$ref; $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref;
$urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id; $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
$genallowed=$user->rights->fournisseur->facture->creer; $genallowed=$user->rights->fournisseur->facture->creer;
$delallowed=$user->rights->fournisseur->facture->supprimer; $delallowed=$user->rights->fournisseur->facture->supprimer;
print '<br>'; print '<br>';
$somethingshown=$formfile->show_documents('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf); $somethingshown=$formfile->show_documents('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf);
$object=$fac; $object=$fac;
@@ -1778,8 +1778,8 @@ else
*/ */
if ($action == 'presend') if ($action == 'presend')
{ {
$ref = dol_sanitizeFileName($fac->ref); $ref = dol_sanitizeFileName($object->ref);
$file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($fac->id,2).$ref.'.pdf'; $file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref.'.pdf';
print '<br>'; print '<br>';
print_titre($langs->trans('SendBillByMail')); print_titre($langs->trans('SendBillByMail'));
@@ -1804,12 +1804,12 @@ else
$formmail->withdeliveryreceipt=1; $formmail->withdeliveryreceipt=1;
$formmail->withcancel=1; $formmail->withcancel=1;
// Tableau des substitutions // Tableau des substitutions
$formmail->substit['__FACREF__']=$fac->ref; $formmail->substit['__FACREF__']=$object->ref;
// Tableau des parametres complementaires // Tableau des parametres complementaires
$formmail->param['action']='send'; $formmail->param['action']='send';
$formmail->param['models']='invoice_supplier_send'; $formmail->param['models']='invoice_supplier_send';
$formmail->param['facid']=$fac->id; $formmail->param['facid']=$object->id;
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?facid='.$fac->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
// Init list of files // Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')

View File

@@ -39,28 +39,29 @@ $langs->load('orders');
$langs->load('companies'); $langs->load('companies');
$langs->load('commercial'); $langs->load('commercial');
// Security check $action = GETPOST('action');
$socid = GETPOST("socid");
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe&fournisseur', $socid, '');
// Security check
$id = (GETPOST("socid") ? GETPOST("socid") : GETPOST("id"));
if ($user->societe_id) $id=$user->societe_id;
$result = restrictedArea($user, 'societe&fournisseur', $id, '');
$object = new Fournisseur($db);
/* /*
* Action * Action
*/ */
if ($_POST['action'] == 'setsupplieraccountancycode') if ($action == 'setsupplieraccountancycode')
{ {
$societe = new Societe($db); $result=$object->fetch($id);
$result=$societe->fetch($_POST['socid']); $object->code_compta_fournisseur=$_POST["supplieraccountancycode"];
$societe->code_compta_fournisseur=$_POST["supplieraccountancycode"]; $result=$object->update($object->id,$user,1,0,1);
$result=$societe->update($societe->id,$user,1,0,1);
if ($result < 0) if ($result < 0)
{ {
$mesg=join(',',$societe->errors); $mesg=join(',',$object->errors);
} }
$POST["action"]=""; $action="";
$socid=$_POST["socid"];
} }
@@ -69,18 +70,17 @@ if ($_POST['action'] == 'setsupplieraccountancycode')
* View * View
*/ */
$societe = new Fournisseur($db);
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
$form = new Form($db); $form = new Form($db);
if ( $societe->fetch($socid) ) if ($object->fetch($id))
{ {
llxHeader('',$langs->trans('SupplierCard')); llxHeader('',$langs->trans('SupplierCard'));
/* /*
* Affichage onglets * Affichage onglets
*/ */
$head = societe_prepare_head($societe); $head = societe_prepare_head($object);
dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"),0,'company');
@@ -90,97 +90,97 @@ if ( $societe->fetch($socid) )
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
print '<tr><td width="20%">'.$langs->trans("ThirdPartyName").'</td><td width="80%" colspan="3">'; print '<tr><td width="20%">'.$langs->trans("ThirdPartyName").'</td><td width="80%" colspan="3">';
$societe->next_prev_filter="te.fournisseur = 1"; $object->next_prev_filter="te.fournisseur = 1";
print $form->showrefnav($societe,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>'; print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{ {
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$societe->prefix_comm.'</td></tr>'; print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
} }
if ($societe->fournisseur) if ($object->fournisseur)
{ {
print '<tr>'; print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans("SupplierCode"). '</td><td colspan="3">'; print '<td nowrap="nowrap">'.$langs->trans("SupplierCode"). '</td><td colspan="3">';
print $societe->code_fournisseur; print $object->code_fournisseur;
if ($societe->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$societe->code_compta_fournisseur,'socid',$societe->id,$user->rights->societe->creer); print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
print '</td><td colspan="3">'; print '</td><td colspan="3">';
print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$societe->code_compta_fournisseur,'socid',$societe->id,$user->rights->societe->creer); print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Address // Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">'; print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
dol_print_address($societe->address,'gmap','thirdparty',$societe->id); dol_print_address($object->address,'gmap','thirdparty',$object->id);
print '</td></tr>'; print '</td></tr>';
// Zip / Town // Zip / Town
print '<tr><td nowrap="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$societe->cp.(($societe->cp && $societe->ville)?' / ':'').$societe->ville.'</td>'; print '<tr><td nowrap="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>';
print '</tr>'; print '</tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
$img=picto_from_langcode($societe->pays_code); $img=picto_from_langcode($object->country_code);
if ($societe->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$societe->pays,$langs->trans("CountryIsInEEC"),1,0); if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$societe->pays; else print ($img?$img.' ':'').$object->country;
print '</td></tr>'; print '</td></tr>';
// Phone // Phone
print '<tr><td>'.$langs->trans("Phone").'</td><td style="min-width: 25%;">'.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'</td>'; print '<tr><td>'.$langs->trans("Phone").'</td><td style="min-width: 25%;">'.dol_print_phone($object->tel,$object->country_code,0,$object->id,'AC_TEL').'</td>';
// Fax // Fax
print '<td>'.$langs->trans("Fax").'</td><td style="min-width: 25%;">'.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'</td></tr>'; print '<td>'.$langs->trans("Fax").'</td><td style="min-width: 25%;">'.dol_print_phone($object->fax,$object->country_code,0,$object->id,'AC_FAX').'</td></tr>';
// EMail // EMail
print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'</td></tr>'; print '<td>'.$langs->trans('EMail').'</td><td colspan="3">'.dol_print_email($object->email,0,$object->id,'AC_EMAIL').'</td></tr>';
// Web // Web
print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\">".dol_print_url($societe->url)."</td></tr>"; print '<tr><td>'.$langs->trans("Web")."</td><td colspan=\"3\">".dol_print_url($object->url)."</td></tr>";
// Assujetti a TVA ou pas // Assujetti a TVA ou pas
print '<tr>'; print '<tr>';
print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">'; print '<td nowrap="nowrap">'.$langs->trans('VATIsUsed').'</td><td colspan="3">';
print yn($societe->tva_assuj); print yn($object->tva_assuj);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Local Taxes // Local Taxes
if($mysoc->pays_code=='ES') if($mysoc->country_code=='ES')
{ {
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
{ {
print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax1IsUsedES').'</td><td colspan="3">'; print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax1IsUsedES').'</td><td colspan="3">';
print yn($societe->localtax1_assuj); print yn($object->localtax1_assuj);
print '</td></tr>'; print '</td></tr>';
print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax2IsUsedES').'</td><td colspan="3">'; print '<tr><td nowrap="nowrap">'.$langs->trans('LocalTax2IsUsedES').'</td><td colspan="3">';
print yn($societe->localtax2_assuj); print yn($object->localtax2_assuj);
print '</td></tr>'; print '</td></tr>';
} }
elseif($mysoc->localtax1_assuj=="1") elseif($mysoc->localtax1_assuj=="1")
{ {
print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
print yn($societe->localtax1_assuj); print yn($object->localtax1_assuj);
print '</td></tr>'; print '</td></tr>';
} }
elseif($mysoc->localtax2_assuj=="1") elseif($mysoc->localtax2_assuj=="1")
{ {
print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
print yn($societe->localtax2_assuj); print yn($object->localtax2_assuj);
print '</td></tr>'; print '</td></tr>';
} }
} }
// TVA Intra // TVA Intra
print '<tr><td nowrap>'.$langs->trans('VATIntraVeryShort').'</td><td colspan="3">'; print '<tr><td nowrap>'.$langs->trans('VATIntraVeryShort').'</td><td colspan="3">';
print $objsoc->tva_intra; print $object->tva_intra;
print '</td></tr>'; print '</td></tr>';
// Module Adherent // Module Adherent
@@ -191,7 +191,7 @@ if ( $societe->fetch($socid) )
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>'; print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
$adh=new Adherent($db); $adh=new Adherent($db);
$result=$adh->fetch('','',$societe->id); $result=$adh->fetch('','',$object->id);
if ($result > 0) if ($result > 0)
{ {
$adh->ref=$adh->getFullName($langs); $adh->ref=$adh->getFullName($langs);
@@ -216,7 +216,7 @@ if ( $societe->fetch($socid) )
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$societe->id.'">'.$langs->trans("ShowSupplierPreview").'</a></td></tr></table></td>'; print '<td align="right"><a href="'.DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id.'">'.$langs->trans("ShowSupplierPreview").'</a></td></tr></table></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
@@ -229,7 +229,7 @@ if ( $societe->fetch($socid) )
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ProductsAndServices").'</td><td align="right">'; print '<td>'.$langs->trans("ProductsAndServices").'</td><td align="right">';
print '<a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$societe->id.'">'.$langs->trans("All").' ('.$societe->NbProduct().')'; print '<a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$object->id.'">'.$langs->trans("All").' ('.$object->NbProduct().')';
print '</a></td></tr></table>'; print '</a></td></tr></table>';
} }
@@ -243,9 +243,10 @@ if ( $societe->fetch($socid) )
if ($user->rights->fournisseur->commande->lire) if ($user->rights->fournisseur->commande->lire)
{ {
// TODO move to DAO class
$sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut"; $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p ";
$sql.= " WHERE p.fk_soc =".$societe->id; $sql.= " WHERE p.fk_soc =".$object->id;
$sql.= " ORDER BY p.date_commande DESC"; $sql.= " ORDER BY p.date_commande DESC";
$sql.= " ".$db->plimit($MAXLIST); $sql.= " ".$db->plimit($MAXLIST);
$resql=$db->query($sql); $resql=$db->query($sql);
@@ -261,8 +262,8 @@ if ( $societe->fetch($socid) )
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'; print '<td colspan="3">';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastOrders",($num<$MAXLIST?"":$MAXLIST)).'</td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastOrders",($num<$MAXLIST?"":$MAXLIST)).'</td>';
print '<td align="right"><a href="commande/liste.php?socid='.$societe->id.'">'.$langs->trans("AllOrders").' ('.$num.')</td>'; print '<td align="right"><a href="commande/liste.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' ('.$num.')</td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$societe->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>'; print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td></tr>'; print '</td></tr>';
} }
@@ -308,11 +309,12 @@ if ( $societe->fetch($socid) )
if ($user->rights->fournisseur->facture->lire) if ($user->rights->fournisseur->facture->lire)
{ {
// TODO move to DAO class
$sql = 'SELECT f.rowid,f.libelle,f.facnumber,f.fk_statut,f.datef as df,f.total_ttc as amount,f.paye,'; $sql = 'SELECT f.rowid,f.libelle,f.facnumber,f.fk_statut,f.datef as df,f.total_ttc as amount,f.paye,';
$sql.= ' SUM(pf.amount) as am'; $sql.= ' SUM(pf.amount) as am';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
$sql.= ' WHERE f.fk_soc = '.$societe->id; $sql.= ' WHERE f.fk_soc = '.$object->id;
$sql.= ' GROUP BY f.rowid,f.libelle,f.facnumber,f.fk_statut,f.datef,f.total_ttc,f.paye'; $sql.= ' GROUP BY f.rowid,f.libelle,f.facnumber,f.fk_statut,f.datef,f.total_ttc,f.paye';
$sql.= ' ORDER BY f.datef DESC'; $sql.= ' ORDER BY f.datef DESC';
$resql=$db->query($sql); $resql=$db->query($sql);
@@ -326,8 +328,8 @@ if ( $societe->fetch($socid) )
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4">'; print '<td colspan="4">';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="facture/index.php?socid='.$societe->id.'">'.$langs->trans('AllBills').' ('.$num.')</td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="facture/index.php?socid='.$object->id.'">'.$langs->trans('AllBills').' ('.$num.')</td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$societe->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>'; print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td></tr>'; print '</td></tr>';
} }
@@ -370,13 +372,13 @@ if ( $societe->fetch($socid) )
if ($user->rights->fournisseur->commande->creer) if ($user->rights->fournisseur->commande->creer)
{ {
$langs->load("orders"); $langs->load("orders");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?action=create&socid='.$societe->id.'">'.$langs->trans("AddOrder").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddOrder").'</a>';
} }
if ($user->rights->fournisseur->facture->creer) if ($user->rights->fournisseur->facture->creer)
{ {
$langs->load("bills"); $langs->load("bills");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?action=create&socid='.$societe->id.'">'.$langs->trans("AddBill").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
} }
// Add action // Add action
@@ -384,7 +386,7 @@ if ( $societe->fetch($socid) )
{ {
if ($user->rights->agenda->myactions->create) if ($user->rights->agenda->myactions->create)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$societe->id.'">'.$langs->trans("AddAction").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a>';
} }
else else
{ {
@@ -404,16 +406,16 @@ if ( $societe->fetch($socid) )
{ {
print '<br>'; print '<br>';
// List of contacts // List of contacts
show_contacts($conf,$langs,$db,$societe,$_SERVER["PHP_SELF"].'?socid='.$societe->id); show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?id='.$object->id);
} }
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{ {
// List of todo actions // List of todo actions
show_actions_todo($conf,$langs,$db,$societe); show_actions_todo($conf,$langs,$db,$object);
// List of done actions // List of done actions
show_actions_done($conf,$langs,$db,$societe); show_actions_done($conf,$langs,$db,$object);
} }
} }
else else

View File

@@ -35,9 +35,12 @@ $langs->load('companies');
$langs->load("suppliers"); $langs->load("suppliers");
$mesg=''; $mesg='';
$action=GETPOST('action');
$id=GETPOST('id');
$id = GETPOST('id');
$action = GETPOST('action');
$confirm = GETPOST('confirm');
$object = new PaiementFourn($db);
/* /*
* Actions * Actions
@@ -46,9 +49,9 @@ $id=GETPOST('id');
if ($action == 'setnote' && $user->rights->fournisseur->facture->creer) if ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
{ {
$db->begin(); $db->begin();
$paiement = new PaiementFourn($db);
$paiement->fetch($id); $object->fetch($id);
$result = $paiement->update_note(GETPOST('note')); $result = $object->update_note(GETPOST('note'));
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();
@@ -56,18 +59,17 @@ if ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
} }
else else
{ {
$mesg='<div class="error">'.$paiement->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
$db->rollback(); $db->rollback();
} }
} }
if ($action == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer)
{ {
$db->begin(); $db->begin();
$paiement = new PaiementFourn($db); $object->fetch($id);
$paiement->fetch($id); $result = $object->delete();
$result = $paiement->delete();
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();
@@ -76,35 +78,33 @@ if ($action == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->
} }
else else
{ {
$mesg='<div class="error">'.$paiement->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
$db->rollback(); $db->rollback();
} }
} }
if ($action == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider) if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider)
{ {
$db->begin(); $db->begin();
$paiement = new PaiementFourn($db); $object->fetch($id);
$paiement->fetch($id); if ($object->valide() >= 0)
if ($paiement->valide() >= 0)
{ {
$db->commit(); $db->commit();
Header('Location: fiche.php?id='.$paiement->id); Header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id);
exit; exit;
} }
else else
{ {
$mesg='<div class="error">'.$paiement->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
$db->rollback(); $db->rollback();
} }
} }
if ($action == 'setnum' && !empty($_POST['num'])) if ($action == 'setnum' && ! empty($_POST['num']))
{ {
$paiement = new PaiementFourn($db); $object->fetch($id);
$paiement->fetch($id); $res = $object->update_num($_POST['num']);
$res = $paiement->update_num($_POST['num']);
if ($res === 0) if ($res === 0)
{ {
$mesg = '<div class="ok">'.$langs->trans('PaymentNumberUpdateSucceeded').'</div>'; $mesg = '<div class="ok">'.$langs->trans('PaymentNumberUpdateSucceeded').'</div>';
@@ -115,12 +115,11 @@ if ($action == 'setnum' && !empty($_POST['num']))
} }
} }
if ($action == 'setdate' && !empty($_POST['dateday'])) if ($action == 'setdate' && ! empty($_POST['dateday']))
{ {
$paiement = new PaiementFourn($db); $object->fetch($id);
$paiement->fetch($id);
$datepaye = dol_mktime(12, 0, 0, $_POST['datemonth'], $_POST['dateday'], $_POST['dateyear']); $datepaye = dol_mktime(12, 0, 0, $_POST['datemonth'], $_POST['dateday'], $_POST['dateyear']);
$res = $paiement->update_date($datepaye); $res = $object->update_date($datepaye);
if ($res === 0) if ($res === 0)
{ {
$mesg = '<div class="ok">'.$langs->trans('PaymentDateUpdateSucceeded').'</div>'; $mesg = '<div class="ok">'.$langs->trans('PaymentDateUpdateSucceeded').'</div>';
@@ -154,8 +153,7 @@ $h++;
dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment'); dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment');
$paiement = new PaiementFourn($db); $result=$object->fetch($id);
$result=$paiement->fetch($id);
if ($result > 0) if ($result > 0)
{ {
/* /*
@@ -163,7 +161,7 @@ if ($result > 0)
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {
$ret=$form->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete'); $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete');
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@@ -172,48 +170,48 @@ if ($result > 0)
*/ */
if ($action == 'valide') if ($action == 'valide')
{ {
$ret=$form->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide'); $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
print '<td valign="top" width="20%" colspan="2">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>'; print '<td valign="top" width="20%" colspan="2">'.$langs->trans('Ref').'</td><td colspan="3">'.$object->id.'</td></tr>';
// Date payment // Date payment
print '<tr><td valign="top" colspan="2">'.$form->editfieldkey("Date",'date',$paiement->date,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">'; print '<tr><td valign="top" colspan="2">'.$form->editfieldkey("Date",'date',$object->date,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Date",'date',$paiement->date,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'day'); print $form->editfieldval("Date",'date',$object->date,'id',$object->id,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'day');
print '</td></tr>'; print '</td></tr>';
// Payment mode // Payment mode
print '<tr><td valign="top" colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$paiement->type_libelle.'</td></tr>'; print '<tr><td valign="top" colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$object->type_libelle.'</td></tr>';
// Payment numero // Payment numero
print '<tr><td valign="top" colspan="2">'.$form->editfieldkey("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">'; print '<tr><td valign="top" colspan="2">'.$form->editfieldkey("Numero",'num',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string'); print $form->editfieldval("Numero",'num',$object->numero,'id',$object->id,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string');
print '</td></tr>'; print '</td></tr>';
// Amount // Amount
print '<tr><td valign="top" colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td valign="top" colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
{ {
print '<tr><td valign="top" colspan="2">'.$langs->trans('Status').'</td><td colspan="3">'.$paiement->getLibStatut(4).'</td></tr>'; print '<tr><td valign="top" colspan="2">'.$langs->trans('Status').'</td><td colspan="3">'.$object->getLibStatut(4).'</td></tr>';
} }
// Note // Note
print '<tr><td valign="top"" colspan="2">'.$form->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->fournisseur->facture->creer).'</td><td colspan="3">'; print '<tr><td valign="top"" colspan="2">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->fournisseur->facture->creer,'text'); print $form->editfieldval("Note",'note',$object->note,'id',$object->id,$user->rights->fournisseur->facture->creer,'text');
print '</td></tr>'; print '</td></tr>';
// Bank account // Bank account
if ($conf->banque->enabled) if ($conf->banque->enabled)
{ {
if ($paiement->bank_account) if ($object->bank_account)
{ {
$bankline=new AccountLine($db); $bankline=new AccountLine($db);
$bankline->fetch($paiement->bank_line); $bankline->fetch($object->bank_line);
print '<tr>'; print '<tr>';
print '<td colspan="2">'.$langs->trans('BankTransactionLine').'</td>'; print '<td colspan="2">'.$langs->trans('BankTransactionLine').'</td>';
@@ -237,7 +235,7 @@ if ($result > 0)
$sql = 'SELECT f.rowid as ref, f.facnumber as ref_supplier, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid'; $sql = 'SELECT f.rowid as ref, f.facnumber as ref_supplier, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid'; $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
$sql .= ' AND pf.fk_paiementfourn = '.$paiement->id; $sql .= ' AND pf.fk_paiementfourn = '.$object->id;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@@ -310,20 +308,20 @@ if ($result > 0)
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
{ {
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '') if ($user->societe_id == 0 && $object->statut == 0 && $action == '')
{ {
if ($user->rights->fournisseur->facture->valider) if ($user->rights->fournisseur->facture->valider)
{ {
print '<a class="butAction" href="fiche.php?id='.$_GET['id'].'&amp;action=valide">'.$langs->trans('Valid').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
} }
} }
} }
if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '') if ($user->societe_id == 0 && $allow_delete && $object->statut == 0 && $action == '')
{ {
if ($user->rights->fournisseur->facture->supprimer) if ($user->rights->fournisseur->facture->supprimer)
{ {
print '<a class="butActionDelete" href="fiche.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
} }
} }

View File

@@ -148,12 +148,12 @@ class ActionsCardProduct extends Product
$this->tpl['showend']=dol_get_fiche_end(); $this->tpl['showend']=dol_get_fiche_end();
// Accountancy buy code // Accountancy buy code
$this->tpl['accountancyBuyCodeKey'] = $form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancyBuyCodeKey'] = $form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer);
$this->tpl['accountancyBuyCodeVal'] = $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancyBuyCodeVal'] = $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer);
// Accountancy sell code // Accountancy sell code
$this->tpl['accountancySellCodeKey'] = $form->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancySellCodeKey'] = $form->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer);
$this->tpl['accountancySellCodeVal'] = $form->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancySellCodeVal'] = $form->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer);
} }
$this->tpl['finished'] = $this->object->finished; $this->tpl['finished'] = $this->object->finished;

View File

@@ -147,12 +147,12 @@ class ActionsCardService extends Product
$this->tpl['showend']=dol_get_fiche_end(); $this->tpl['showend']=dol_get_fiche_end();
// Accountancy buy code // Accountancy buy code
$this->tpl['accountancyBuyCodeKey'] = $form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancyBuyCodeKey'] = $form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer);
$this->tpl['accountancyBuyCodeVal'] = $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancyBuyCodeVal'] = $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer);
// Accountancy sell code // Accountancy sell code
$this->tpl['accountancySellCodeKey'] = $form->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancySellCodeKey'] = $form->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer);
$this->tpl['accountancySellCodeVal'] = $form->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer); $this->tpl['accountancySellCodeVal'] = $form->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer);
} }
$this->tpl['finished'] = $this->object->finished; $this->tpl['finished'] = $this->object->finished;

View File

@@ -1012,13 +1012,13 @@ else
print '</tr>'; print '</tr>';
// Accountancy sell code // Accountancy sell code
print '<tr><td>'.$form->editfieldkey("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,'id',$object->id,$user->rights->produit->creer).'</td><td colspan="2">'; print '<tr><td>'.$form->editfieldkey("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,$object,$user->rights->produit->creer).'</td><td colspan="2">';
print $form->editfieldval("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,'id',$object->id,$user->rights->produit->creer); print $form->editfieldval("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,$object,$user->rights->produit->creer);
print '</td></tr>'; print '</td></tr>';
// Accountancy buy code // Accountancy buy code
print '<tr><td>'.$form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,'id',$object->id,$user->rights->produit->creer).'</td><td colspan="2">'; print '<tr><td>'.$form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,$object,$user->rights->produit->creer).'</td><td colspan="2">';
print $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,'id',$object->id,$user->rights->produit->creer); print $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,$object,$user->rights->produit->creer);
print '</td></tr>'; print '</td></tr>';
// Status (to sell) // Status (to sell)

View File

@@ -277,8 +277,8 @@ if ($_GET["id"] || $_GET["ref"])
} }
// Stock // Stock
print '<tr><td>'.$form->editfieldkey("StockLimit",'stocklimit',$product->seuil_stock_alerte,'id',$product->id,$user->rights->produit->creer).'</td><td colspan="2">'; print '<tr><td>'.$form->editfieldkey("StockLimit",'stocklimit',$product->seuil_stock_alerte,$product,$user->rights->produit->creer).'</td><td colspan="2">';
print $form->editfieldval("StockLimit",'stocklimit',$product->seuil_stock_alerte,'id',$product->id,$user->rights->produit->creer); print $form->editfieldval("StockLimit",'stocklimit',$product->seuil_stock_alerte,$product,$user->rights->produit->creer);
print '</td></tr>'; print '</td></tr>';
// Last movement // Last movement