diff --git a/dashboard/dashboard.php b/dashboard/dashboard.php index c72c46fd..8b69bc0d 100644 --- a/dashboard/dashboard.php +++ b/dashboard/dashboard.php @@ -506,14 +506,13 @@ function orders_menu( $arg ) { function orders_module( $url ) { global $current_user; -if ( isset($_GET['id']) && $_GET['id'] > 0 ) { - -$request = "/orders/".esc_attr($_GET['id'])."?contact_list=0"; -$orderfo = callDoliApi("GET", $request, null, dolidelay('order', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); -//print $orderfo; -} + if ( isset($_GET['id']) && $_GET['id'] > 0 ) { + $request = "/orders/".esc_attr($_GET['id'])."?contact_list=0"; + $orderfo = callDoliApi("GET", $request, null, dolidelay('order', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); + } + $thirdparty = doliConnect('thirdparty', $current_user, false, esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null)); -if ( !isset($orderfo->error) && isset($_GET['id']) && isset($_GET['ref']) && (doliconnector($current_user, 'fk_soc') == $orderfo->socid ) && ($_GET['ref'] == $orderfo->ref) && $orderfo->statut != 0 && isset($_GET['security']) && wp_verify_nonce( $_GET['security'], 'doli-orders-'.$orderfo->id.'-'.$orderfo->ref)) { +if ( !isset($orderfo->error) && isset($_GET['id']) && isset($_GET['ref']) && ($thirdparty->id == $orderfo->socid ) && ($_GET['ref'] == $orderfo->ref) && $orderfo->statut != 0 && isset($_GET['security']) && wp_verify_nonce( $_GET['security'], 'doli-orders-'.$orderfo->id.'-'.$orderfo->ref)) { print '
'.sprintf(__( 'Order %s', 'doliconnect'), $orderfo->ref).' '.__( 'Back', 'doliconnect').'
'; print doliObjectInfos($orderfo); @@ -527,7 +526,7 @@ function orders_module( $url ) { $return = add_query_arg( $arr_params, doliconnecturl('dolicart')); if ( $orderfo->mode_reglement_code == 'CHQ' ) { - $listpaymentmethods = callDoliApi("GET", "/doliconnector/".doliconnector($current_user, 'fk_soc')."/paymentmethods?type=order&rowid=".$orderfo->id, null, dolidelay('paymentmethods', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); + $listpaymentmethods = callDoliApi("GET", "/doliconnector/".$thirdparty->id."/paymentmethods?type=order&rowid=".$orderfo->id, null, dolidelay('paymentmethods', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); print "

".sprintf( __( 'Please send your cheque in the amount of %1$s with reference %2$s to %3$s at the following address', 'doliconnect'), doliprice($orderfo, 'ttc', isset($orderfo->multicurrency_code) ? $orderfo->multicurrency_code : null), $orderfo->ref, $listpaymentmethods->CHQ->proprio).":

"; print "

".$listpaymentmethods->CHQ->owner_address."

"; @@ -535,7 +534,7 @@ function orders_module( $url ) { print "
"; } elseif ( $orderfo->mode_reglement_code == 'VIR' ) { - $listpaymentmethods = callDoliApi("GET", "/doliconnector/".doliconnector($current_user, 'fk_soc')."/paymentmethods", null, dolidelay('paymentmethods', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); + $listpaymentmethods = callDoliApi("GET", "/doliconnector/".$thirdparty->id."/paymentmethods", null, dolidelay('paymentmethods', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); print "

".sprintf( __( 'Please send your transfert in the amount of %1$s with reference %2$s at the following account', 'doliconnect'), doliprice($orderfo, 'ttc', isset($orderfo->multicurrency_code) ? $orderfo->multicurrency_code : null), $orderfo->ref ).":"; if (isset($listpaymentmethods->VIR->bank)) print "
".__( 'Bank', 'doliconnect').": ".$listpaymentmethods->VIR->bank.""; @@ -568,7 +567,6 @@ function orders_module( $url ) { print "


"; -$thirdparty = callDoliApi("GET", "/thirdparties/".doliconnector($current_user, 'fk_soc'), null, dolidelay('thirdparty', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); print "
"; if (!empty($orderfo->contacts_ids) && is_array($orderfo->contacts_ids)) { foreach ($orderfo->contacts_ids as $contact) { @@ -727,7 +725,7 @@ function orders_module( $url ) { } else { $limit=12; $page = doliPG(isset($_GET['pg'])?$_GET['pg']:null); - $request= "/orders?sortfield=t.date_valid&sortorder=DESC&limit=".$limit."&page=".$page."&thirdparty_ids=".doliconnector($current_user, 'fk_soc')."&pagination_data=true&sqlfilters=(t.fk_statut:!=:'0')"; + $request= "/orders?sortfield=t.date_valid&sortorder=DESC&limit=".$limit."&page=".$page."&thirdparty_ids=".$thirdparty->id."&pagination_data=true&sqlfilters=(t.fk_statut:!=:'0')"; $object = callDoliApi("GET", $request, null, dolidelay('order', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); if ( doliversion('20.0.0') && isset($object->data) ) { $listorder = $object->data; } else { $listorder = $object; } @@ -770,14 +768,13 @@ function invoices_menu( $arg ) { function invoices_module( $url ) { global $current_user; -if ( isset($_GET['id']) && $_GET['id'] > 0 ) { - -$request = "/invoices/".esc_attr($_GET['id'])."?contact_list=0"; -$invoicefo = callDoliApi("GET", $request, null, dolidelay('invoice', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); -//print $orderfo; -} + if ( isset($_GET['id']) && $_GET['id'] > 0 ) { + $request = "/invoices/".esc_attr($_GET['id'])."?contact_list=0"; + $invoicefo = callDoliApi("GET", $request, null, dolidelay('invoice', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); + } + $thirdparty = doliConnect('thirdparty', $current_user, false, esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null)); -if ( !isset($orderfo->error) && isset($_GET['id']) && isset($_GET['ref']) && (doliconnector($current_user, 'fk_soc') == $invoicefo->socid ) && ($_GET['ref'] == $invoicefo->ref) && $invoicefo->statut != 0 && isset($_GET['security']) && wp_verify_nonce( $_GET['security'], 'doli-invoices-'.$invoicefo->id.'-'.$invoicefo->ref)) { +if ( !isset($orderfo->error) && isset($_GET['id']) && isset($_GET['ref']) && ($thirdparty->id == $invoicefo->socid ) && ($_GET['ref'] == $invoicefo->ref) && $invoicefo->statut != 0 && isset($_GET['security']) && wp_verify_nonce( $_GET['security'], 'doli-invoices-'.$invoicefo->id.'-'.$invoicefo->ref)) { print '
'.sprintf(__( 'Invoice %s', 'doliconnect'), $invoicefo->ref).' '.__( 'Back', 'doliconnect').'
'; print doliObjectInfos($invoicefo); @@ -794,7 +791,7 @@ function invoices_module( $url ) { $return = add_query_arg( $arr_params, doliconnecturl('dolicart')); if ( $invoicefo->mode_reglement_code == 'CHQ' ) { -$listpaymentmethods = callDoliApi("GET", "/doliconnector/".doliconnector($current_user, 'fk_soc')."/paymentmethods?type=order&rowid=".$invoicefo->id, null, dolidelay('paymentmethods', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); +$listpaymentmethods = callDoliApi("GET", "/doliconnector/".$thirdparty->id."/paymentmethods?type=order&rowid=".$invoicefo->id, null, dolidelay('paymentmethods', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); print "

".sprintf( __( 'Please send your cheque in the amount of %1$s with reference %2$s to %3$s at the following address', 'doliconnect'), doliprice($invoicefo, 'ttc', isset($invoicefo->multicurrency_code) ? $invoicefo->multicurrency_code : null), $invoicefo->ref, $listpaymentmethods->CHQ->proprio).":

"; print "

".$listpaymentmethods->CHQ->owner_address."

"; @@ -802,7 +799,7 @@ function invoices_module( $url ) { print "
"; } elseif ( $invoicefo->mode_reglement_code == 'VIR' ) { -$listpaymentmethods = callDoliApi("GET", "/doliconnector/".doliconnector($current_user, 'fk_soc')."/paymentmethods", null, dolidelay('paymentmethods', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); +$listpaymentmethods = callDoliApi("GET", "/doliconnector/".$thirdparty->id."/paymentmethods", null, dolidelay('paymentmethods', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); print "

".sprintf( __( 'Please send your transfert in the amount of %1$s with reference %2$s at the following account', 'doliconnect'), doliprice($invoicefo, 'ttc', isset($invoicefo->multicurrency_code) ? $invoicefo->multicurrency_code : null), $invoicefo->ref ).":"; print "
".__( 'Bank', 'doliconnect').": ".$listpaymentmethods->VIR->bank.""; @@ -835,8 +832,6 @@ function invoices_module( $url ) { print "


"; -$thirdparty = callDoliApi("GET", "/thirdparties/".doliconnector($current_user, 'fk_soc'), null, dolidelay('thirdparty', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); - print "
"; if (!empty($invoicefo->contacts_ids) && is_array($invoicefo->contacts_ids)) { @@ -955,7 +950,7 @@ function invoices_module( $url ) { } else { $limit=12; $page = doliPG(isset($_GET['pg'])?$_GET['pg']:null); - $request= "/invoices?sortfield=t.datec&sortorder=DESC&limit=".$limit."&page=".$page."&thirdparty_ids=".doliconnector($current_user, 'fk_soc')."&pagination_data=true&sqlfilters=(t.fk_statut:!=:0)"; + $request= "/invoices?sortfield=t.datec&sortorder=DESC&limit=".$limit."&page=".$page."&thirdparty_ids=".$thirdparty->id."&pagination_data=true&sqlfilters=(t.fk_statut:!=:0)"; $object = callDoliApi("GET", $request, null, dolidelay('invoice', esc_attr(isset($_GET["refresh"]) ? $_GET["refresh"] : null))); if ( doliversion('20.0.0') && isset($object->data) ) { $listinvoice = $object->data; } else { $listinvoice = $object; }