Skip to content

Commit

Permalink
Merge pull request #73 from Eoxia/2.3.3
Browse files Browse the repository at this point in the history
2.3.3
  • Loading branch information
nicolas-eoxia authored Feb 5, 2021
2 parents 6a48626 + 1059199 commit 6e5e849
Show file tree
Hide file tree
Showing 20 changed files with 315 additions and 143 deletions.
Binary file modified core/asset/language/wpshop-fr_FR.mo
Binary file not shown.
193 changes: 110 additions & 83 deletions core/asset/language/wpshop-fr_FR.po

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions modules/checkout/action/class-checkout-action.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ public function callback_checkout_create_third() {

if ( ! is_user_logged_in() ) {
$third_party = Third_Party::g()->update( $posted_data['third_party'] );
// Call wpshop to update attached ERP.
do_action( 'wps_checkout_create_third_party', $third_party );

$posted_data['contact']['login'] = sanitize_user( current( explode( '@', $posted_data['contact']['email'] ) ), true );
$posted_data['contact']['password'] = wp_generate_password();
Expand All @@ -262,6 +260,9 @@ public function callback_checkout_create_third() {
$third_party->data['contact_ids'][] = $contact->data['id'];
$third_party = Third_Party::g()->update( $third_party->data );

// Call wpshop to update attached ERP.
do_action( 'wps_checkout_create_third_party', $third_party );

// Call wpshop to update attached ERP.
do_action( 'wps_checkout_create_contact', $contact );

Expand Down Expand Up @@ -416,6 +417,7 @@ public function callback_checkout_proposal( $third_party, $contact ) {
* @param User $contact Les données du contact.
*/
public function callback_checkout_doli_proposal( $third_party, $contact ) {

$type_payment = ! empty( $_POST['type_payment'] ) ? sanitize_text_field( $_POST['type_payment'] ) : '';

$proposal_data = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public function add_meta_box() {
* @version 2.0.0
*/
public function callback_admin_menu() {
add_submenu_page( 'wpshop', __( 'Invoices', 'wpshop' ), __( 'Invoices', 'wpshop' ), 'manage_options', 'wps-invoice', array( $this, 'callback_add_menu_page' ) );
if ( Settings::g()->dolibarr_is_active() ) {
add_submenu_page('wpshop', __('Invoices', 'wpshop'), __('Invoices', 'wpshop'), 'manage_options', 'wps-invoice', array($this, 'callback_add_menu_page'));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,21 @@ public function metabox_order_details( $order ) {
* La metabox des paiements d'une commande
*
* @since 2.0.0
* @version 2.0.0
* @version 2.3.3
*
* @param Doli_Order $order Les données d'une commande.
*/
public function metabox_order_payment( $order ) {
$dolibarr_option = get_option( 'wps_dolibarr', Settings::g()->default_settings );

$doli_invoices = array();
$wp_invoices = array();

// Facture is the key getted from Dolibarr. Facture is french name for say "Invoice".
if ( ! empty( $order->data['linked_objects_ids']['facture'] ) ) {
$route = 'invoices?sortfield=t.rowid&sortorder=ASC&limit=100&sqlfilters=';
foreach ( $order->data['linked_objects_ids']['facture'] as $doli_invoice_id ) {
$route .= '(t.rowid:=:' . $doli_invoice_id . ') or';
$route .= 't.rowid=' . $doli_invoice_id . ' or ';
}

$route = substr( $route, 0, strlen( $route ) - 3 );
Expand Down Expand Up @@ -300,6 +302,7 @@ public function metabox_order_payment( $order ) {
'already_paid' => $already_paid,
'total_ttc_invoices' => $total_ttc_invoices,
'remaining_unpaid' => $remaining_unpaid,
'doli_url' => $dolibarr_option['dolibarr_url'],
) );
}

Expand Down Expand Up @@ -414,7 +417,6 @@ public function create_order( $proposal ) {

$wp_order = Doli_Order::g()->get( array( 'schema' => true ), true );
$wp_order = Doli_Order::g()->doli_to_wp( $doli_order, $wp_order, true );

return $wp_order;
}

Expand Down
8 changes: 5 additions & 3 deletions modules/dolibarr/doli-order/class/class-doli-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,21 @@ public function doli_to_wp( $doli_order, $wp_order, $only_convert = false ) {
$status = 'publish';
break;
case 2:
$status = 'wps-shipmentprocess';
break;
case 3:
$status = 'wps-delivered';
$wp_order->data['delivered'] = 1;
if ( $wp_order->data['billed'] ) {
$status = 'wps-billed';
}
break;
default:
$status = 'publish';
break;
}

if ( $wp_order->data['billed'] ) {
$status = 'wps-billed';

if ( $wp_order->data['billed'] && $status = 'wps-billed' ) {
if ( ! $only_convert ) {
Product_Downloadable::g()->create_from_order( $wp_order );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Eoxia <[email protected]>
* @copyright (c) 2011-2020 Eoxia <[email protected]>.
* @since 2.0.0
* @version 2.0.0
* @version 2.3.3
*/

namespace wpshop;
Expand Down Expand Up @@ -106,7 +106,7 @@ public function add_review_order_table_class( $class, $object ) {
* Change le statut d'une commande.
*
* @since 2.0.0
* @version 2.0.0
* @version 2.3.3
*
* @param string $status Le statut d'une facture.
* @param Doli_Invoice $object Les données d'une facture.
Expand All @@ -119,8 +119,8 @@ public function wps_doli_status( $status, $object ) {
return __( 'Traitment in progress', 'wpshop' );
}

if ( $object->data['delivered'] ) {
return $status . ' ' . __( '(Delivery)', 'wpshop' );
if ( $object->data['billed'] ) {
return $status . ' - ' . __( 'Billed', 'wpshop' );
}
}

Expand Down
12 changes: 11 additions & 1 deletion modules/dolibarr/doli-order/view/metabox-order-payment.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Eoxia <[email protected]>
* @copyright (c) 2011-2020 Eoxia <[email protected]>.
* @since 2.0.0
* @version 2.0.0
* @version 2.3.3
*/

namespace wpshop;
Expand Down Expand Up @@ -70,4 +70,14 @@
</tr>
</tfoot>
</table>

<?php if ( ! empty( $invoices ) ) :
foreach ( $invoices as $invoice ) : ?>
<ul class="reference-title">
<?php if ( ! empty( $invoice->data['external_id'] ) ) : ?>
<li><a href="<?php echo esc_attr( $doli_url ); ?>/compta/facture/card.php?facid=<?php echo $invoice->data['external_id']; ?>" target="_blank"><?php echo esc_html( $invoice->data['title'] ); ?></a></li>
<?php endif; ?>
</ul>
<?php endforeach;
endif; ?>
</div>
4 changes: 1 addition & 3 deletions modules/dolibarr/doli-payment/class/class-doli-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ public function convert_to_wp( $payment_method ) {
$payment_methods_option = get_option( 'wps_payment_methods', Payment::g()->default_options );

if ( 'CB' === $payment_method ) {
return 'paypal';
} elseif ( 'STR' === $payment_method ) {
return 'stripe';
return 'carte_bancaire';
} elseif ( 'CHQ' === $payment_method ) {
return 'cheque';
} elseif ( 'LIQ' === $payment_method ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Eoxia <[email protected]>
* @copyright (c) 2011-2020 Eoxia <[email protected]>.
* @since 2.0.0
* @version 2.0.0
* @version 2.3.3
*/

namespace wpshop;
Expand Down Expand Up @@ -53,7 +53,7 @@ protected function construct() {}
* Synchronise Dolibarr vers WPshop.
*
* @since 2.0.0
* @version 2.0.0
* @version 2.3.3
*
* @param stdClass $doli_proposal Les données d'une proposition commerciale Dolibarr.
* @param Proposals $wp_proposal Les données d'une proposition commerciale WordPress.
Expand Down Expand Up @@ -116,7 +116,7 @@ public function doli_to_wp( $doli_proposal, $wp_proposal ) {
$status = 'wps-refused';
break;
case 4:
$status = 'publish';
$status = 'wps-billed';
$wp_proposal->data['billed'] = 1;
break;
default:
Expand Down
7 changes: 4 additions & 3 deletions modules/dolibarr/doli-proposals/doli-proposals.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "Doli Proposals",
"slug": "doli-proposals",
"since": "2.0.0",
"version": "2.0.0",
"version": "2.3.3",
"description": "Le module gérant les propositions commerciales",
"path": "modules/dolibarr/doli-proposals/",
"dependencies": {
"class": {},
"action": {}
"filter": {},
"class": {},
"action": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* La classe gérant les filtres des propositions commerciales de Dolibarr.
*
* @package WPshop
* @author Eoxia <[email protected]>
* @copyright (c) 2011-2020 Eoxia <[email protected]>.
* @since 2.3.3
* @version 2.3.3
*/

namespace wpshop;

defined( 'ABSPATH' ) || exit;

/**
* Doli Proposals Filter Class.
*/
class Doli_Proposals_Filter {

/**
* Le constructeur.
*
* @since 2.3.3
* @version 2.3.3
*/
public function __construct() {
add_filter( 'wps_doli_status', array( $this, 'wps_doli_status' ), 10, 2 );
}

/**
* Change le statut d'une proposition commerciale.
*
* @since 2.3.3
* @version 2.3.3
*
* @param string $status Le statut d'une proposition commerciale.
* @param Proposals $object Les données d'une proposition commerciale.
*
* @return string Le nouveau statut d'une proposition commerciale.
*/
public function wps_doli_status( $status, $object ) {
if ( $object->data['type'] == Proposals::g()->get_type() ) {
switch ($object->data['status']) {
case 'publish':
$status .= __(' (open proposal)', 'wpshop');
break;
case 'wps-accepted':
$status .= __(' (to be invoiced)', 'wpshop');
break;
case 'wps-refused':
$status .= __(' (closed)', 'wpshop');
break;
}
}
return $status;
}
}

new Doli_Proposals_Filter();
2 changes: 2 additions & 0 deletions modules/dolibarr/doli-proposals/filter/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Silence is golden.
26 changes: 15 additions & 11 deletions modules/dolibarr/doli-statut/class/class-doli-statut.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Eoxia <[email protected]>
* @copyright (c) 2011-2020 Eoxia <[email protected]>.
* @since 2.0.0
* @version 2.0.0
* @version 2.3.3
*/

namespace wpshop;
Expand Down Expand Up @@ -35,7 +35,7 @@ class Doli_Statut extends Singleton_Util {
* Le constructeur.
*
* @since 2.0.0
* @version 2.0.0
* @version 2.3.3
*/
protected function construct() {
$this->status = array(
Expand All @@ -45,20 +45,20 @@ protected function construct() {
'class' => 'status-grey',
),
'publish' => array(
'text' => __( 'Waiting for a signature', 'wpshop' ),
'text' => __( 'Validated', 'wpshop' ),
'class' => 'status-orange',
),
'wps-accepted' => array(
'text' => __( 'Signed', 'wpshop' ),
'class' => 'status-orange',
'class' => 'status-green',
),
'wps-refused' => array(
'text' => __( 'Not signed', 'wpshop' ),
'class' => 'status-red',
'class' => 'status-grey',
),
'wps-billed' => array(
'text' => __( 'Billed', 'wpshop' ),
'class' => 'status-green',
'class' => 'status-grey',
),
'wps-delivered' => array(
'text' => __( 'Delivered', 'wpshop' ),
Expand All @@ -71,15 +71,19 @@ protected function construct() {
'class' => 'status-grey',
),
'publish' => array(
'text' => __( 'Not paid', 'wpshop' ),
'text' => __( 'Validated', 'wpshop' ),
'class' => 'status-orange',
),
'wps-canceled' => array(
'text' => __( 'Canceled', 'wpshop' ),
'class' => 'status-red',
),
'wps-billed' => array(
'text' => __( 'Billed', 'wpshop' ),
'text' => __( 'Processed', 'wpshop' ),
'class' => 'status-grey',
),
'wps-shipmentprocess' => array(
'text' => __( 'In progress', 'wpshop' ),
'class' => 'status-green',
),
'wps-delivered' => array(
Expand All @@ -93,12 +97,12 @@ protected function construct() {
'class' => 'status-grey',
),
'publish' => array(
'text' => __( 'Not paid', 'wpshop' ),
'text' => __( 'Unpaid', 'wpshop' ),
'class' => 'status-orange',
),
'wps-billed' => array(
'text' => __( 'Billed', 'wpshop' ),
'class' => 'status-green',
'text' => __( 'Paid', 'wpshop' ),
'class' => 'status-grey',
),
'wps-abandoned' => array(
'text' => __( 'Abandoned', 'wpshop' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public function wp_to_doli( $wp_third_party, $doli_third_party, $save = true, &$
'errors' => array(),
'messages' => array(),
) ) {
$contact = User::g()->get( array( 'id' => $wp_third_party->data['contact_ids'][0] ), true );

$data = array(
'name' => $wp_third_party->data['title'],
'country' => $wp_third_party->data['country'],
Expand All @@ -127,7 +129,8 @@ public function wp_to_doli( $wp_third_party, $doli_third_party, $save = true, &$
'client' => 1,
'code_client' => 'auto',
'array_options' => array(
'options__wps_id' => $wp_third_party->data['id'],
'options_firstname' => $contact->data['firstname'],
'options__wps_id' => $wp_third_party->data['id'],
),
);

Expand Down
Loading

0 comments on commit 6e5e849

Please sign in to comment.