diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index a6c9bf3079d..ffbd9e7c2e2 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -40,11 +40,13 @@ if (! $user->societe_id == 0) $entitytoicon=array( 'invoice'=>'bill','invoice_line'=>'bill', + 'order'=>'order','order_line'=>'order', 'member'=>'user', 'member_type'=>'group'); $entitytolang=array( 'user'=>'User', 'company'=>'Company','contact'=>'Contact', 'invoice'=>'Bill','invoice_line'=>'InvoiceLine', + 'order'=>'Order','order_line'=>'OrderLine', 'member'=>'Member','member_type'=>'MemberType'); $array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array(); diff --git a/htdocs/includes/modules/modCommande.class.php b/htdocs/includes/modules/modCommande.class.php index 633d8303df8..09ad56ece4d 100644 --- a/htdocs/includes/modules/modCommande.class.php +++ b/htdocs/includes/modules/modCommande.class.php @@ -93,48 +93,86 @@ class modCommande extends DolibarrModules // Permissions $this->rights = array(); $this->rights_class = 'commande'; - - $this->rights[1][0] = 81; - $this->rights[1][1] = 'Lire les commandes clients'; - $this->rights[1][2] = 'r'; - $this->rights[1][3] = 1; - $this->rights[1][4] = 'lire'; - - $this->rights[2][0] = 82; - $this->rights[2][1] = 'Créer modifier les commandes clients'; - $this->rights[2][2] = 'w'; - $this->rights[2][3] = 0; - $this->rights[2][4] = 'creer'; - - $this->rights[3][0] = 84; - $this->rights[3][1] = 'Valider les commandes clients'; - $this->rights[3][2] = 'd'; - $this->rights[3][3] = 0; - $this->rights[3][4] = 'valider'; - $this->rights[4][0] = 86; - $this->rights[4][1] = 'Envoyer les commandes clients'; - $this->rights[4][2] = 'd'; - $this->rights[4][3] = 0; - $this->rights[4][4] = 'envoyer'; - - $this->rights[5][0] = 87; - $this->rights[5][1] = 'Clôturer les commandes clients'; - $this->rights[5][2] = 'd'; - $this->rights[5][3] = 0; - $this->rights[5][4] = 'cloturer'; - - $this->rights[6][0] = 88; - $this->rights[6][1] = 'Annuler les commandes clients'; - $this->rights[6][2] = 'd'; - $this->rights[6][3] = 0; - $this->rights[6][4] = 'annuler'; + $r=0; - $this->rights[7][0] = 89; - $this->rights[7][1] = 'Supprimer les commandes clients'; - $this->rights[7][2] = 'd'; - $this->rights[7][3] = 0; - $this->rights[7][4] = 'supprimer'; + $r++; + $this->rights[$r][0] = 81; + $this->rights[$r][1] = 'Lire les commandes clients'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'lire'; + + $r++; + $this->rights[$r][0] = 82; + $this->rights[$r][1] = 'Créer modifier les commandes clients'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'creer'; + + $r++; + $this->rights[$r][0] = 84; + $this->rights[$r][1] = 'Valider les commandes clients'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'valider'; + + $r++; + $this->rights[$r][0] = 86; + $this->rights[$r][1] = 'Envoyer les commandes clients'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'envoyer'; + + $r++; + $this->rights[$r][0] = 87; + $this->rights[$r][1] = 'Clôturer les commandes clients'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'cloturer'; + + $r++; + $this->rights[$r][0] = 88; + $this->rights[$r][1] = 'Annuler les commandes clients'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'annuler'; + + $r++; + $this->rights[$r][0] = 89; + $this->rights[$r][1] = 'Supprimer les commandes clients'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'supprimer'; + + $r++; + $this->rights[$r][0] = 1420; + $this->rights[$r][1] = 'Exporter les commandes clients et attributs'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'commande'; + $this->rights[$r][5] = 'export'; + + // Exports + //-------- + $r=0; + + $r++; + $this->export_code[$r]=$this->id.'_'.$r; + $this->export_label[$r]='Commandes clients et lignes de commande'; + $this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','c.rowid'=>"Id",'c.ref'=>"Ref",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"DateOrder",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total_ttc'=>"TotalTTC",'c.facture'=>"OrderShortStatusInvoicee",'c.fk_statut'=>'Status','c.note'=>"Note",'cd.rowid'=>'LineId','cd.description'=>"LineDescription",'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty"); + $this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','c.rowid'=>"order",'c.ref'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>'order','c.note'=>"order",'cd.rowid'=>'order_line','cd.description'=>"order_line",'cd.tva_tx'=>"order_line",'cd.qty'=>"order_line"); + $this->export_alias_array[$r]=array('s.idp'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','c.rowid'=>"orderid",'c.ref'=>"ref",'c.fk_soc'=>"fk_soc",'c.date_creation'=>"datecreation",'c.date_commande'=>"dateorder",'c.amount_ht'=>"amount",'c.remise_percent'=>"globaldiscount",'c.total_ht'=>"totalht",'c.total_ttc'=>"totalttc",'c.facture'=>"invoicee",'c.fk_statut'=>'status','c.note'=>"note",'cd.rowid'=>'lineid','cd.description'=>"linedescription",'cd.tva_tx'=>"linevatrate",'cd.qty'=>"lineqty"); + $this->export_sql[$r]="select distinct "; + $i=0; + foreach ($this->export_alias_array[$r] as $key => $value) + { + if ($i > 0) $this->export_sql[$r].=', '; + else $i++; + $this->export_sql[$r].=$key.' as '.$value; + } + $this->export_sql[$r].=' from '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd, '.MAIN_DB_PREFIX.'societe as s WHERE c.fk_soc = s.idp AND c.rowid = cd.fk_facture'; + $this->export_permission[$r]=array(array("commande","commande","export")); }