Merge branch 'develop' into patch-11
This commit is contained in:
commit
aa19c92bf4
25 changed files with 51 additions and 44 deletions
|
|
@ -67,7 +67,7 @@ $function = 'textgeneration';
|
|||
$generatedContent = $ai->generateContent($instructions, 'auto', $function);
|
||||
|
||||
if (is_array($generatedContent) && $generatedContent['error']) {
|
||||
print "Error : " . $generatedContent['message'];
|
||||
print "Error returned by API call: " . $generatedContent['message'];
|
||||
} else {
|
||||
print $generatedContent;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ class Ai
|
|||
*/
|
||||
public function generateContent($instructions, $model = 'auto', $function = 'textgeneration')
|
||||
{
|
||||
if (empty($this->apiKey)) {
|
||||
return array('error' => true, 'message' => 'API key is no defined');
|
||||
}
|
||||
|
||||
if (empty($this->apiEndpoint)) {
|
||||
if ($function == 'textgeneration') {
|
||||
$this->apiEndpoint = 'https://api.openai.com/v1/chat/completions';
|
||||
|
|
@ -97,6 +101,8 @@ class Ai
|
|||
}
|
||||
}
|
||||
|
||||
dol_syslog("Call API for apiEndpoint=".$this->apiEndpoint." apiKey=".substr($this->apiKey, 0, 3).'***********, model='.$model);
|
||||
|
||||
try {
|
||||
$configurationsJson = getDolGlobalString('AI_CONFIGURATIONS_PROMPT');
|
||||
$configurations = json_decode($configurationsJson, true);
|
||||
|
|
|
|||
|
|
@ -254,8 +254,8 @@ class doc_generic_asset_odt extends ModelePDFAsset
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,8 +264,8 @@ class doc_generic_bom_odt extends ModelePDFBom
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,8 +270,8 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,8 +268,8 @@ class doc_generic_contract_odt extends ModelePDFContract
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,8 +268,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,8 +268,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,8 +260,8 @@ class doc_generic_member_odt extends ModelePDFMember
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,8 +257,8 @@ class doc_generic_mo_odt extends ModelePDFMo
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,8 +266,8 @@ class doc_generic_product_odt extends ModelePDFProduct
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -555,8 +555,8 @@ class doc_generic_project_odt extends ModelePDFProjects
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,8 +303,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@ class doc_generic_reception_odt extends ModelePdfReception
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,8 +248,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
|||
$newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)) . '-' . $newfiletmp;
|
||||
$newfiletmp = preg_replace('/__+/', '_', $newfiletmp); // Replace repeated _ into one _ (to avoid string with substitution syntax)
|
||||
}
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,8 +269,8 @@ class doc_generic_stock_odt extends ModelePDFStock
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,8 +266,8 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,8 +290,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,8 +258,8 @@ class doc_generic_ticket_odt extends ModelePDFTicket
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -292,8 +292,8 @@ class doc_generic_user_odt extends ModelePDFUser
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,8 +291,8 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
|
|||
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ $langs->loadLangs(array('ecm', 'companies', 'other', 'users', 'orders', 'propal'
|
|||
|
||||
// Get parameters
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$socid = GETPOSTINT('socid');
|
||||
|
|
|
|||
|
|
@ -278,8 +278,8 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
|
|||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
// Get extension (ods or odt)
|
||||
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
|
||||
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
|
||||
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
|
||||
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
|
||||
if ($format == '1') {
|
||||
$format = '%Y%m%d%H%M%S';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4951,7 +4951,7 @@ class Societe extends CommonObject
|
|||
*/
|
||||
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $langs;
|
||||
|
||||
if (!empty($moreparams) && !empty($moreparams['use_companybankid'])) {
|
||||
$modelpath = "core/modules/bank/doc/";
|
||||
|
|
|
|||
Loading…
Reference in a new issue