function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') { global $db, $conf, $langs; dol_syslog("Function: getThirdParty login="******" id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext); if ($authentication['entity']) { $conf->entity = $authentication['entity']; } // Init and check authentication $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); // Check parameters if (!$error && ($id && $ref || $id && $ref_ext || $ref && $ref_ext)) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; } if (!$error) { $fuser->getrights(); if ($fuser->rights->societe->lire) { $thirdparty = new Societe($db); $result = $thirdparty->fetch($id, $ref, $ref_ext); if ($result > 0) { $thirdparty_result_fields = array('id' => $thirdparty->id, 'ref' => $thirdparty->name, 'ref_ext' => $thirdparty->ref_ext, 'status' => $thirdparty->status, 'client' => $thirdparty->client, 'supplier' => $thirdparty->fournisseur, 'customer_code' => $thirdparty->code_client, 'supplier_code' => $thirdparty->code_fournisseur, 'customer_code_accountancy' => $thirdparty->code_compta, 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur, 'fk_user_author' => $thirdparty->fk_user_author, 'date_creation' => dol_print_date($thirdparty->date_creation, 'dayhourrfc'), 'date_modification' => dol_print_date($thirdparty->date_modification, 'dayhourrfc'), 'address' => $thirdparty->address, 'zip' => $thirdparty->zip, 'town' => $thirdparty->town, 'province_id' => $thirdparty->state_id, 'country_id' => $thirdparty->country_id, 'country_code' => $thirdparty->country_code, 'country' => $thirdparty->country, 'phone' => $thirdparty->phone, 'fax' => $thirdparty->fax, 'email' => $thirdparty->email, 'url' => $thirdparty->url, 'profid1' => $thirdparty->idprof1, 'profid2' => $thirdparty->idprof2, 'profid3' => $thirdparty->idprof3, 'profid4' => $thirdparty->idprof4, 'profid5' => $thirdparty->idprof5, 'profid6' => $thirdparty->idprof6, 'capital' => $thirdparty->capital, 'barcode' => $thirdparty->barcode, 'vat_used' => $thirdparty->tva_assuj, 'vat_number' => $thirdparty->tva_intra, 'note_private' => $thirdparty->note_private, 'note_public' => $thirdparty->note_public); //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('societe', true); //Get extrafield values $thirdparty->fetch_optionals($thirdparty->id, $extralabels); foreach ($extrafields->attribute_label as $key => $label) { $thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_' . $key => $thirdparty->array_options['options_' . $key])); } // Create $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'thirdparty' => $thirdparty_result_fields); } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id=' . $id . ' nor ref=' . $ref . ' nor ref_ext=' . $ref_ext; } } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">'; print '</center>'; print '</form>'; dol_fiche_end(); } } else { /* * View */ $object = new Societe($db); $res = $object->fetch($socid); if ($res < 0) { dol_print_error($db, $object->error); exit; } $res = $object->fetch_optionals($object->id, $extralabels); //if ($res < 0) { dol_print_error($db); exit; } $head = societe_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); // Confirm delete third party if ($action == 'delete' || $conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { print $form->formconfirm($_SERVER["PHP_SELF"] . "?socid=" . $object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); } dol_htmloutput_errors($error, $errors); $showlogo = $object->logo; $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { $showbarcode = 0; } print '<table class="border" width="100%">'; // Ref