diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 6339ce4a91a..397910a6e2f 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -129,6 +129,75 @@ class Documents extends DolibarrApi return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); } + /** + * Return the list of documents of an element + * + * @param string $modulepart Name of module or area concerned ('facture', 'project', 'member', ...) + * @param int $id ID of element + * @param string $ref Ref of element + * @return array Array of documents with path + * + * @throws RestException + * + * @url GET list + */ + function getDocumentsListByElement($modulepart, $id=0, $ref='') + { + global $conf; + + if (empty($modulepart)) { + throw new RestException(400, 'bad value for parameter modulepart'); + } + + if (empty($id) && empty($ref)) { + throw new RestException(400, 'bad value for parameter id or ref'); + } + + $id = (empty($id)?0:$id); + + if ($modulepart == 'societe' || $modulepart == 'thirdparty') + { + if (!DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + $object = new Societe($this->db); + $result=$object->fetch($id, $ref); + if ( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; + } + else if ($modulepart == 'adherent' || $modulepart == 'member') + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } + + $object = new Adherent($this->db); + $result=$object->fetch($id, $ref); + if ( ! $result ) { + throw new RestException(404, 'Member not found'); + } + + $upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); + } + else + { + throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); + } + + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + if (empty($filearray)) { + throw new RestException(404, 'Modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' and Ref '.$object->ref:'').' does not have any documents.'); + } + + return $filearray; + } + /** * Return a document. diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 4975e00279d..95a9ea250a1 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -44,6 +44,7 @@ print ''.$langs->trans("Position"); print ''; print ''; print ''.$langs->trans("Label").''; +print ''.$langs->trans("TranslationString").''; print ''.$langs->trans("AttributeCode").''; print ''.$langs->trans("Type").''; print ''.$langs->trans("Size").''; @@ -71,6 +72,7 @@ if (count($extrafields->attribute_type)) print ''; print "".$extrafields->attribute_pos[$key]."\n"; print "".$extrafields->attribute_label[$key]."\n"; // We don't translate here, we want admin to know what is the key not translated value + print "".$langs->trans($extrafields->attribute_label[$key])."\n"; print "".$key."\n"; print "".$type2label[$extrafields->attribute_type[$key]]."\n"; print ''.$extrafields->attribute_size[$key]."\n"; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index d440396d0c3..cf1c7afad9c 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -481,7 +481,7 @@ class Expedition extends CommonObject // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut"; + $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.billed"; $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; $sql.= ", e.fk_shipping_method, e.tracking_number"; @@ -525,7 +525,7 @@ class Expedition extends CommonObject $this->tracking_number = $obj->tracking_number; $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility $this->origin_id = $obj->origin_id; - $this->billed = ($obj->fk_statut==2?1:0); + $this->billed = $obj->billed; $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units;