diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index dae5fb70617..e63d09afcb7 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent @@ -927,6 +927,15 @@ if ($action == 'create') if ($id > 0) { $result1=$object->fetch($id); + if ($result1 <= 0) + { + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); + + llxFooter(); + exit; + } + $result2=$object->fetch_thirdparty(); $result2=$object->fetch_projet(); $result3=$object->fetch_contact(); @@ -957,7 +966,7 @@ if ($id > 0) $object->note = GETPOST("note",'none'); } - if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) + if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) { dol_print_error($db,$object->error); exit; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6c863580203..c73216bbc22 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -621,7 +621,7 @@ class ActionComm extends CommonObject $this->contact->id = $obj->fk_contact; // deprecated $this->fk_element = $obj->elementid; - $this->elementid = $obj->elementid; + $this->elementid = $obj->elementid; $this->elementtype = $obj->elementtype; $this->fetchResources(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index e49fe43e2c9..12fe76a522a 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1335,11 +1335,10 @@ class Propal extends CommonObject $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid'; - $sql.= " WHERE p.fk_statut = c.id"; if ($ref) { $sql.= " AND p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid - $sql.= " AND p.ref='".$ref."'"; + $sql.= " AND p.ref='".$this->db->escape($ref)."'"; } else $sql.= " AND p.rowid=".$rowid; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 1ce48a7371d..114490fa373 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -197,7 +197,7 @@ $now=dol_now(); $form=new Form($db); $sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut,"; -$sql.= " s.rowid as socid, s.nom as name,"; +$sql.= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,"; $sql.= " cd.rowid, cd.description, cd.statut,"; $sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; @@ -540,6 +540,11 @@ while ($i < min($num,$limit)) $contractstatic->id=$obj->cid; $contractstatic->ref=$obj->ref?$obj->ref:$obj->cid; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->email=$obj->email; + $companystatic->client=$obj->client; + $companystatic->fournisseur=$obj->fournisseur; print ''; @@ -555,7 +560,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.description']['checked'])) { print ''; - if ($obj->pid) + if ($obj->pid > 0) { $productstatic->id=$obj->pid; $productstatic->type=$obj->ptype; @@ -625,9 +630,6 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['s.nom']['checked'])) { print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=1; print $companystatic->getNomUrl(1,'customer',28); print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index d936c01139f..62898fc40a3 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -160,6 +160,7 @@ class doc_generic_project_odt extends ModelePDFProjects 'task_description'=>$task->description, 'task_fk_parent'=>$task->fk_parent, 'task_duration'=>$task->duration, + 'task_duration_hour'=>convertSecondToTime($task->duration,'all'), 'task_progress'=>$task->progress, 'task_public'=>$task->public, 'task_date_start'=>dol_print_date($task->date_start,'day'), @@ -317,7 +318,10 @@ class doc_generic_project_odt extends ModelePDFProjects 'tasktime_fk_user'=>$tasktime['fk_user'], 'tasktime_user_name'=>$tasktime['name'], 'tasktime_user_first'=>$tasktime['firstname'], - 'tasktime_fullcivname'=>$tasktime['fullcivname'] + 'tasktime_fullcivname'=>$tasktime['fullcivname'], + 'tasktime_amountht'=>$tasktime['amountht'], + 'tasktime_amountttc'=>$tasktime['amountttc'], + 'tasktime_thm'=>$tasktime['thm'], ); } @@ -698,7 +702,7 @@ class doc_generic_project_odt extends ModelePDFProjects //Time ressources $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; - $sql.= ", u.lastname, u.firstname"; + $sql.= ", u.lastname, u.firstname, t.thm"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_task =".$task->id; @@ -712,6 +716,35 @@ class doc_generic_project_odt extends ModelePDFProjects $i = 0; $tasks = array(); $listlinestasktime = $listlines->__get('taskstimes'); + if (empty($num)) { + $row['rowid']=''; + $row['task_date']=''; + $row['task_duration']=''; + $row['$tasktime']=''; + $row['note']=''; + $row['fk_user']=''; + $row['name']=''; + $row['firstname']=''; + $row['fullcivname']=''; + $row['amountht']=''; + $row['amountttc']=''; + $row['thm']=''; + $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs); + foreach($tmparray as $key => $val) + { + try + { + $listlinestasktime->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlinestasktime->merge(); + } while ($i < $num) { $row = $this->db->fetch_array($resql); @@ -723,6 +756,16 @@ class doc_generic_project_odt extends ModelePDFProjects $row['fullcivname']=''; } + if (!empty($row['thm'])) { + $row['amountht']=($row['task_duration'] / 3600) * $row['thm']; + $defaultvat = get_default_tva($mysoc, $mysoc); + $row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');; + } else { + $row['amountht']=0; + $row['amountttc']=0; + $row['thm']=0; + } + $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs); foreach($tmparray as $key => $val) @@ -884,60 +927,114 @@ class doc_generic_project_odt extends ModelePDFProjects //List of referent - $listofreferent=array( - 'propal'=>array( - 'title'=>"ListProposalsAssociatedProject", - 'class'=>'Propal', - 'table'=>'propal', - 'test'=>$conf->propal->enabled && $user->rights->propale->lire), - 'order'=>array( - 'title'=>"ListOrdersAssociatedProject", - 'class'=>'Commande', - 'table'=>'commande', - 'test'=>$conf->commande->enabled && $user->rights->commande->lire), - 'invoice'=>array( - 'title'=>"ListInvoicesAssociatedProject", - 'class'=>'Facture', - 'table'=>'facture', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), - 'invoice_predefined'=>array( - 'title'=>"ListPredefinedInvoicesAssociatedProject", - 'class'=>'FactureRec', - 'table'=>'facture_rec', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), - 'order_supplier'=>array( - 'title'=>"ListSupplierOrdersAssociatedProject", - 'table'=>'commande_fournisseur', - 'class'=>'CommandeFournisseur', - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), - 'invoice_supplier'=>array( - 'title'=>"ListSupplierInvoicesAssociatedProject", - 'table'=>'facture_fourn', - 'class'=>'FactureFournisseur', - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), - 'contract'=>array( - 'title'=>"ListContractAssociatedProject", - 'class'=>'Contrat', - 'table'=>'contrat', - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), - 'intervention'=>array( - 'title'=>"ListFichinterAssociatedProject", - 'class'=>'Fichinter', - 'table'=>'fichinter', - 'disableamount'=>1, - 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), - 'trip'=>array( - 'title'=>"ListTripAssociatedProject", - 'class'=>'Deplacement', - 'table'=>'deplacement', - 'disableamount'=>1, - 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), - 'agenda'=>array( - 'title'=>"ListActionsAssociatedProject", - 'class'=>'ActionComm', - 'table'=>'actioncomm', - 'disableamount'=>1, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) + $listofreferent = array( + 'propal' => array( + 'title' => "ListProposalsAssociatedProject", + 'class' => 'Propal', + 'table' => 'propal', + 'test' => $conf->propal->enabled && $user->rights->propale->lire + ), + 'order' => array( + 'title' => "ListOrdersAssociatedProject", + 'class' => 'Commande', + 'table' => 'commande', + 'test' => $conf->commande->enabled && $user->rights->commande->lire + ), + 'invoice' => array( + 'title' => "ListInvoicesAssociatedProject", + 'class' => 'Facture', + 'table' => 'facture', + 'test' => $conf->facture->enabled && $user->rights->facture->lire + ), + 'invoice_predefined' => array( + 'title' => "ListPredefinedInvoicesAssociatedProject", + 'class' => 'FactureRec', + 'table' => 'facture_rec', + 'test' => $conf->facture->enabled && $user->rights->facture->lire + ), + 'proposal_supplier' => array( + 'title' => "ListSupplierProposalsAssociatedProject", + 'class' => 'SupplierProposal', + 'table' => 'supplier_proposal', + 'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire + ), + 'order_supplier' => array( + 'title' => "ListSupplierOrdersAssociatedProject", + 'table' => 'commande_fournisseur', + 'class' => 'CommandeFournisseur', + 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire + ), + 'invoice_supplier' => array( + 'title' => "ListSupplierInvoicesAssociatedProject", + 'table' => 'facture_fourn', + 'class' => 'FactureFournisseur', + 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire + ), + 'contract' => array( + 'title' => "ListContractAssociatedProject", + 'class' => 'Contrat', + 'table' => 'contrat', + 'test' => $conf->contrat->enabled && $user->rights->contrat->lire + ), + 'intervention' => array( + 'title' => "ListFichinterAssociatedProject", + 'class' => 'Fichinter', + 'table' => 'fichinter', + 'disableamount' => 1, + 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire + ), + 'shipping' => array( + 'title' => "ListShippingAssociatedProject", + 'class' => 'Expedition', + 'table' => 'expedition', + 'disableamount' => 1, + 'test' => $conf->expedition->enabled && $user->rights->expedition->lire + ), + 'trip' => array( + 'title' => "ListTripAssociatedProject", + 'class' => 'Deplacement', + 'table' => 'deplacement', + 'disableamount' => 1, + 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire + ), + 'expensereport' => array( + 'title' => "ListExpenseReportsAssociatedProject", + 'class' => 'ExpenseReportLine', + 'table' => 'expensereport_det', + 'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire + ), + 'donation' => array( + 'title' => "ListDonationsAssociatedProject", + 'class' => 'Don', + 'table' => 'don', + 'test' => $conf->don->enabled && $user->rights->don->lire + ), + 'loan' => array( + 'title' => "ListLoanAssociatedProject", + 'class' => 'Loan', + 'table' => 'loan', + 'test' => $conf->loan->enabled && $user->rights->loan->read + ), + 'chargesociales' => array( + 'title' => "ListSocialContributionAssociatedProject", + 'class' => 'ChargeSociales', + 'table' => 'chargesociales', + 'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $id, + 'test' => $conf->tax->enabled && $user->rights->tax->charges->lire + ), + 'stock_mouvement' => array( + 'title' => "ListMouvementStockProject", + 'class' => 'MouvementStock', + 'table' => 'stock_mouvement', + 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) + ), + 'agenda' => array( + 'title' => "ListActionsAssociatedProject", + 'class' => 'ActionComm', + 'table' => 'actioncomm', + 'disableamount' => 1, + 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire + ) ); //Insert reference diff --git a/htdocs/install/doctemplates/projects/template_project.odt b/htdocs/install/doctemplates/projects/template_project.odt index fca796a26dd..b6fd0349ea4 100644 Binary files a/htdocs/install/doctemplates/projects/template_project.odt and b/htdocs/install/doctemplates/projects/template_project.odt differ diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 8a720bd422b..6e4de1188a6 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -5,10 +5,10 @@ SelectThirdParty=Select a third party ConfirmDeleteCompany=Are you sure you want to delete this company and all inherited information? DeleteContact=Delete a contact/address ConfirmDeleteContact=Are you sure you want to delete this contact and all inherited information? -MenuNewThirdParty=new Third Party -MenuNewCustomer=new Customer -MenuNewProspect=new Prospect -MenuNewSupplier=new Vendor +MenuNewThirdParty=New Third Party +MenuNewCustomer=New Customer +MenuNewProspect=Nnew Prospect +MenuNewSupplier=New Vendor MenuNewPrivateIndividual=New private individual NewCompany=New company (prospect, customer, vendor) NewThirdParty=New Third Party (prospect, customer, vendor) @@ -333,7 +333,7 @@ NoContactForAnyProposal=This contact is not a contact for any commercial proposa NoContactForAnyContract=This contact is not a contact for any contract NoContactForAnyInvoice=This contact is not a contact for any invoice NewContact=New contact -NewContactAddress=new Contact/Address +NewContactAddress=New Contact/Address MyContacts=My contacts Capital=Capital CapitalOf=Capital of %s