diff --git a/backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css b/backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css
index 430216a..b943d1f 100644
--- a/backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css
+++ b/backend/app/plugins/wiaas/assets/css/wiaas-admin-delivery-process.css
@@ -1,10 +1,3 @@
-.wiaas_delivery_step_nav {
-
-
-
-}
-
-
-.gravityflow_workflow_detail #postbox-container-1 > div:nth-child(2) {
+.gravityflow_workflow_detail #postbox-container-1 > div:last-child:not(.detail-view-print) {
display: none;
}
diff --git a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php
index caf1120..65ccdcc 100644
--- a/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php
+++ b/backend/app/plugins/wiaas/includes/admin/class-wiaas-admin-delivery-process.php
@@ -4,17 +4,9 @@ class Wiaas_Admin_Delivery_Process {
public static function init() {
- add_action( 'gravityflow_entry_detail', array( __CLASS__, 'display_process_steps_details' ), 10, 3 );
-
- add_action( 'gravityflow_title_entry_detail', array( __CLASS__, 'process_title' ), 10, 3 );
-
- add_action('add_meta_boxes', array(__CLASS__, 'add_delivery_process_metabox'), 100);
-
- add_action( 'wp_ajax_wiaas_create_order_delivery_process', array(__CLASS__, 'wiaas_ajax_create_order_delivery_process') );
-
- add_action('gravityflow_entry_detail', array(__CLASS__, 'maybe_display_delivery_process_navigation'), 9, 3);
-
- add_filter('gravityflow_admin_action_feedback', array(__CLASS__, 'maybe_process_admin_step_change_action'), 10, 4);
+ require_once dirname( __FILE__ ) . '/delivery-process/wiaas-admin-delivery-process-ajax.php';
+ require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-flow.php';
+ require_once dirname( __FILE__ ) . '/delivery-process/class-wiaas-admin-delivery-process-order.php';
add_action( 'admin_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'), 100 );
}
@@ -26,421 +18,6 @@ class Wiaas_Admin_Delivery_Process {
wp_enqueue_script( 'wiaas_admin_delivery_process', $plugin_url . '/assets/js/wiaas-admin-delivery-process.js' );
wp_enqueue_style( 'wiaas_admin_delivery_process', $plugin_url . '/assets/css/wiaas-admin-delivery-process.css' );
}
-
-
- public static function add_delivery_process_metabox() {
-
- add_meta_box(
- 'order_delivery_process_meta_box',
- __('Delivery Process', 'cmb'),
- array(__CLASS__, 'order_delivery_process_meta_box'),
- 'shop_order',
- 'side',
- 'high'
- );
- }
-
-
- public static function maybe_process_admin_step_change_action($feedback, $admin_action, $form, $entry) {
-
- $admin_action = rgpost( 'wiaas_delivery_process_navigation_action' );
-
- list( $base_admin_action, $action_id ) = rgexplode( '|', $admin_action, 2 );
-
- if ( $base_admin_action == 'send_to_step' ) {
- $step_id = $action_id;
- $api = new Gravity_Flow_API( $form['id'] );
- $api->send_to_step( $entry, $step_id );
- $entry = GFAPI::get_entry( $entry['id'] );
- $new_step = $api->get_current_step( $entry );
- $feedback = $new_step ?
- sprintf( esc_html__( 'Sent to step: %s', 'wiaas' ), $new_step->get_name() ) :
- esc_html__( 'Workflow Complete', 'wiaas' );
- }
-
- return $feedback;
- }
-
-
- public static function maybe_display_delivery_process_navigation($form, $entry, $current_step) {
-
- if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) || empty( $current_step ) ) {
- return;
- }
-
- $steps = gravity_flow()->get_steps($form['id'], $entry);
-
- // get next step id
- $next_step = gravity_flow()->get_next_step($current_step, $entry, $form);
- $next_step_id = empty($next_step) ? null : $next_step->get_id();
-
- // get previous step id
- foreach ($steps as $step) {
-
- $next = gravity_flow()->get_next_step($step, $entry, $form);
- if ($next && $next->get_id() === $current_step->get_id()) {
- $previous_step = $step;
- }
- }
- $previous_step_id = empty($previous_step) ? null : $previous_step->get_id();
-
- // bail out if none exist
- if ( empty($next_step_id) && empty($previous_step_id) ) {
-
- return;
- }
-
- /**
- * @reference Gravity_Flow::maybe_process_admin_action for used field names
- * which are being checked there
- *
- */
-
- ?>
-
-
-
-
-
-
-
- class="button wiaas_delivery_step_nav"
- style="float:right; margin-left: 20px;" value="NEXT STEP">
-
-
- class="button wiaas_delivery_step_nav"
- style="float:right;" value="PREV STEP">
-
- get_current_step(GFAPI::get_entry($process_entry_id));
-
- $entry_url = $step->get_entry_url();
-
- wp_send_json_success(array(
- 'url' => $entry_url
- ));
- }
-
- wp_send_json_error($error);
- }
-
-
- public static function order_delivery_process_meta_box() {
-
- global $post;
-
- $order_id = $post->ID;
-
- $process_entry = Wiaas_Delivery_Process::get_order_delivery_process_entry($order_id);
-
- if ( empty($process_entry) ){
-
- $order = wc_get_order($order_id);
-
- $list_of_delivery_processes = Wiaas_Delivery_Process::get_available_process_list_for_country(
- Wiaas_Countries::get_country_code_by_currency($order->get_currency())
- );
-
- ?>
-
-
-
-
- Assign process to order ...
- $process){
- echo '' . $process['title'] . ' ';
- }
- ?>
-
-
-
Assign
-
-
-
-
- 'gravityflow-inbox',
- 'view' => 'entry',
- 'id' => $process_entry['form_id'],
- 'lid' => $process_entry['id']
- ), admin_url() );
-
- ?>
- Delivery Process
- id];
- }
- }
-
- // display process steps
-
- $workflow_api = new Gravity_Flow_API($form['id']);
-
- $steps = $workflow_api->get_steps();
-
- ?>
-
-
-
-
- Order placed
-
-
-
-
-
-
- Assign process
-
-
-
- $step) {
-
- if (! $step->is_active()) {
- continue;
- }
-
- $is_step_completed = $step->get_status() === 'complete' || $step->get_status() === 'approved';
- $is_current_step = $current_step && $step->get_id() === $current_step->get_id();
-
- if ($is_current_step) {
- $style = 'color: #FD8049;';
- } else if ($is_step_completed) {
- $style = 'color: #34C388;';
- } else {
- $style = 'opacity: 0.5; color: #CCC;';
- }
-
- ?>
-
-
-
-
-
- get_name(), 'wiaas') ?>
-
-
- target_form_id );
-
- if (empty($action_form)) {
-
- echo '';
-
- continue;
- }
-
- $action_delivery_settings = rgar($action_form, 'wiaas_delivery_process');
-
- ?>
-
-
-
-
-
- ' .
- ' ' . $action_form['title'] . '',
- $form_url );
-
- echo $form_link;
- }
-
- echo ' ';
-
- $page_size = 20;
- $search_criteria = array(
- 'status' => 'active',
- 'field_filters' => array(
- array( 'key' => 'wiaas_delivery_process_id',
- 'value' => $entry['id']
- ),
- ),
- );
- $sorting = array( 'key' => 'date_created', 'direction' => 'DESC' );
- $paging = array( 'offset' => 0, 'page_size' => $page_size );
-
- $entries = GFAPI::get_entries( $action_form, $search_criteria, $sorting, $paging );
-
- foreach ($entries as $action_entry) {
- self::_display_step_action_entry($action_form, $action_entry);
- }
-
- ?>
-
-
-
-
-
-
-
-
- get_current_step($action_entry);
-
-
- ?>
-
-
- type === 'wiaas_order') {
- continue;
- }
-
- if ($field->type === 'workflow_discussion') {
-
- echo '' . $field->format_discussion_value($action_entry[$field->id]) . ' ';
-
- continue;
- }
-
- $value = $field->get_value_entry_detail($action_entry[$field->id]);
- $label = $field->get_field_label(false, $action_entry[$field->id]);
-
- echo '' .
- '' . $label . ' : ' .
- '' . $value . ' ' .
- ' ';
- }
-
- ?>
-
-
-
-
-
-
- get_status_label($current_action_step->get_status()) . ': ' . $current_action_step->get_name();
- echo '' .
- ' ' .
- ' ';
-
- } else {
- echo $workflow_api->get_status($action_entry);
- }
- ?>
-
-
-
-
-
-
-
-
-
-
-
+
+
+ get_steps();
+
+ /**
+ * Disable if:
+ * - actions for customer config validation is not done
+ * - action for customer acceptance is active or completed
+ */
+ $is_disabled = false;
+ foreach ($steps as $step) {
+
+ if (Wiaas_Delivery_Process_Action::process_step_has_customer_validate_questionnaires_action($step) &&
+ $step->get_status() !== 'complete') {
+
+ $is_disabled = true;
+ break;
+ }
+
+ if (Wiaas_Delivery_Process_Action::process_step_has_customer_acceptance_action($step) &&
+ ($step->get_id() === $current_step->get_id() || $step->get_status() === 'complete')) {
+
+ $is_disabled = true;
+ break;
+ }
+ }
+
+ $order_id = $entry['wiaas_delivery_order_id'];
+
+ $suppliers = wiaas_get_order_delivery_suppliers($order_id);
+ $final_estimated_date = Wiaas_Order::get_final_estimated_date($order_id);
+ $final_confirmed_date = Wiaas_Order::get_final_confirmed_date($order_id);
+ $earliest_installation_date = Wiaas_Order::get_earliest_installation_date($order_id);
+
+ require 'views/html-order-suppliers-delivery-dates.php';
+ }
+
+ public static function maybe_process_admin_step_change_action($feedback, $admin_action, $form, $entry) {
+
+ $admin_action = rgpost( 'wiaas_delivery_process_navigation_action' );
+
+ list( $base_admin_action, $action_id ) = rgexplode( '|', $admin_action, 2 );
+
+ if ( $base_admin_action == 'send_to_step' ) {
+ $step_id = $action_id;
+ $api = new Gravity_Flow_API( $form['id'] );
+ $api->send_to_step( $entry, $step_id );
+ $entry = GFAPI::get_entry( $entry['id'] );
+ $new_step = $api->get_current_step( $entry );
+ $feedback = $new_step ?
+ sprintf( esc_html__( 'Sent to step: %s', 'wiaas' ), $new_step->get_name() ) :
+ esc_html__( 'Workflow Complete', 'wiaas' );
+ }
+
+ return $feedback;
+ }
+
+ public static function maybe_display_delivery_process_navigation($form, $entry, $current_step) {
+
+ if(! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
+ empty( $current_step ) ||
+ Wiaas_Delivery_Process_Action::is_action_form($form) ) {
+ return;
+ }
+
+ $steps = gravity_flow()->get_steps($form['id'], $entry);
+
+ // get next step id
+ $next_step = gravity_flow()->get_next_step($current_step, $entry, $form);
+ $next_step_id = empty($next_step) ? null : $next_step->get_id();
+
+ // get previous step id
+ foreach ($steps as $step) {
+
+ $next = gravity_flow()->get_next_step($step, $entry, $form);
+ if ($next && $next->get_id() === $current_step->get_id()) {
+ $previous_step = $step;
+ }
+ }
+ $previous_step_id = empty($previous_step) ? null : $previous_step->get_id();
+
+ // bail out if none exist
+ if ( empty($next_step_id) && empty($previous_step_id) ) {
+
+ return;
+ }
+
+ /**
+ * @reference Gravity_Flow::maybe_process_admin_action for used field names
+ * which are being checked there
+ *
+ */
+
+ ?>
+
+
+
+
+
+
+
+ class="button button-primary wiaas_delivery_step_nav"
+ style="float:right; margin-left: 20px;" value="NEXT STEP">
+
+
+ class="button button-primary wiaas_delivery_step_nav"
+ style="float:right;" value="PREV STEP">
+
+ id];
+ }
+ }
+
+ // display process steps
+
+ $workflow_api = new Gravity_Flow_API($form['id']);
+
+ $steps = $workflow_api->get_steps();
+
+ ?>
+
+
+
+
+ Order placed
+
+
+
+
+
+
+ Assign process
+
+
+
+ $step) {
+
+ if (! $step->is_active()) {
+ continue;
+ }
+
+ $is_step_completed = $step->get_status() === 'complete' || $step->get_status() === 'approved';
+ $is_current_step = $current_step && $step->get_id() === $current_step->get_id();
+
+ if ($is_current_step) {
+ $style = 'color: #FD8049;';
+ } else if ($is_step_completed) {
+ $style = 'color: #34C388;';
+ } else {
+ $style = 'opacity: 0.5; color: #CCC;';
+ }
+
+ ?>
+
+
+
+
+
+ get_name(), 'wiaas') ?>
+
+
+ target_form_id );
+
+ if (empty($action_form)) {
+
+ echo '';
+
+ continue;
+ }
+
+ $action_delivery_settings = rgar($action_form, 'wiaas_delivery_process');
+
+ ?>
+
+
+
+
+
+ ' .
+ ' ' . $action_form['title'] . '',
+ $form_url );
+
+ echo $form_link;
+ }
+
+ echo ' ';
+
+ $page_size = 20;
+ $search_criteria = array(
+ 'status' => 'active',
+ 'field_filters' => array(
+ array( 'key' => 'wiaas_delivery_process_id',
+ 'value' => $entry['id']
+ ),
+ ),
+ );
+ $sorting = array( 'key' => 'date_created', 'direction' => 'DESC' );
+ $paging = array( 'offset' => 0, 'page_size' => $page_size );
+
+ $entries = GFAPI::get_entries( $action_form, $search_criteria, $sorting, $paging );
+
+ foreach ($entries as $action_entry) {
+ self::_display_step_action_entry($action_form, $action_entry);
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+ get_current_step($action_entry);
+
+
+ ?>
+
+
+ type === 'wiaas_order') {
+ continue;
+ }
+
+ if ($field->type === 'workflow_discussion') {
+
+ echo '' . $field->format_discussion_value($action_entry[$field->id]) . ' ';
+
+ continue;
+ }
+
+ $value = $field->get_value_entry_detail($action_entry[$field->id]);
+ $label = $field->get_field_label(false, $action_entry[$field->id]);
+
+ echo '' .
+ '' . $label . ' : ' .
+ '' . $value . ' ' .
+ ' ';
+ }
+
+ ?>
+
+
+
+
+
+
+ get_status_label($current_action_step->get_status()) . ': ' . $current_action_step->get_name();
+ echo '' .
+ ' ' .
+ ' ';
+
+ } else {
+ echo $workflow_api->get_status($action_entry);
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+ ID;
+
+ $process_entry = Wiaas_Delivery_Process::get_order_delivery_process_entry($order_id);
+
+ if ( empty($process_entry) ) {
+
+ $order = wc_get_order($order_id);
+
+ $list_of_delivery_processes = Wiaas_Delivery_Process::get_available_process_list_for_country(
+ Wiaas_Countries::get_country_code_by_currency($order->get_currency())
+ );
+
+ ?>
+
+
+ Assign process to order ...
+ $process){
+ echo '' . $process['title'] . ' ';
+ }
+ ?>
+
+ Assign
+
+ 'gravityflow-inbox',
+ 'view' => 'entry',
+ 'id' => $process_entry['form_id'],
+ 'lid' => $process_entry['id']
+ ), admin_url() );
+
+ ?>
+ Delivery Process
+ 403 ) );
+ }
+
+ $order_id = $_GET['wiaas-procurement-order-id'];
+ $order = wc_get_order($order_id);
+
+ if (! $order) {
+ wp_die( __( 'Invalid order.', 'wiaas' ), __( 'Download Error', 'wiaas' ), array( 'response' => 404 ) );
+ }
+
+ $customer_user_id = $order->get_customer_id();
+ $organization_id = wiaas_get_user_organization_id($customer_user_id);
+ $customer_organization_info = wiaas_get_organization_info($organization_id);
+
+ $delivery_address = $order->get_shipping_address_1() . ',' .
+ $order->get_shipping_city() . ',' .
+ $order->get_shipping_country() . ',' .
+ $order->get_shipping_postcode();
+ $billing_address = $order->get_billing_address_1() . ',' .
+ $order->get_billing_city() . ',' .
+ $order->get_billing_country() . ',' .
+ $order->get_billing_postcode();
+
+ $order_procurement_info = wiaas_get_order_procurement_info($order->get_id());
+
+ $spreadsheet = new Spreadsheet();
+ $spreadsheet->getProperties()->setCreator("RICOH")
+ ->setLastModifiedBy("Ricoh Dash")
+ ->setTitle("Order Procurement Report")
+ ->setSubject("Order Procurement Report")
+ ->setDescription("Order Procurement Report")
+ ->setKeywords("office 2007 openxml php order procurement")
+ ->setCategory("Procurement report file");
+
+ $spreadsheet->setActiveSheetIndex(0);
+ $sheet = $spreadsheet->getActiveSheet();
+ $sheet->setTitle('Order procurement');
+
+ $sheet->setCellValue('A1', 'Customer details');
+ $sheet->setCellValue('A2', 'Name');
+ $sheet->setCellValue('A3', 'Invoice address');
+ $sheet->setCellValue('A4', 'Invoice Full Name');
+ $sheet->setCellValue('A5', 'Invoice Email');
+ $sheet->setCellValue('A6', 'VAT Number');
+
+ $sheet->setCellValue('B2', ! empty($customer_organization_info) ? $customer_organization_info['name'] : '');
+ $sheet->setCellValue('B3', $billing_address);
+ $sheet->setCellValue('B4', $order->get_formatted_billing_full_name());
+ $sheet->setCellValue('B5', $order->get_billing_email());
+ $sheet->setCellValue('B6', ! empty($customer_organization_info) ? $customer_organization_info['vat_code'] : '');
+
+ $sheet->getStyle('A1')->getFont()->setBold(true);
+
+ $sheet->setCellValue('A9', 'OrderDetails');
+ $sheet->setCellValue('A10', 'Order number');
+ $sheet->setCellValue('A11', 'Project number');
+ $sheet->setCellValue('A12', 'Delivery addres');
+ $sheet->setCellValue('A13', 'Delivery Full Name');
+ $sheet->setCellValue('A14', 'Reference');
+ $sheet->setCellValue('B10', $order->get_order_number());
+ $sheet->setCellValue('B11', Wiaas_Order_Project::get_project_name_for_order($order->get_id()) );
+ $sheet->setCellValue('B12', $delivery_address);
+ $sheet->setCellValue('B13', $order->get_formatted_shipping_full_name());
+ $sheet->setCellValue('B14', $order->get_meta('_wiaas_reference'));
+
+ $sheet->getStyle('A9')->getFont()->setBold(true);
+
+ $row = 14;
+
+ foreach ($order_procurement_info as $category => $products) {
+
+ $col = 1; $row += 2;
+
+ $sheet->getColumnDimensionByColumn($col)->setAutoSize(true);
+ $sheet->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true);
+
+ $sheet->setCellValueByColumnAndRow($col, $row, ucfirst(strtolower($category)));
+
+ $row += 2;
+
+ if (! empty($products)) {
+
+ $product_columns = array_keys($products[0]);
+
+ foreach ($product_columns as $product_column_index => $product_column) {
+
+ $sheet->getColumnDimensionByColumn($product_column_index + 1)->setAutoSize(true);
+ $sheet->getStyleByColumnAndRow($product_column_index + 1, $row)->getFont()->setBold(true);
+ $sheet->setCellValueByColumnAndRow($product_column_index + 1, $row, $product_column);
+ }
+ }
+
+ $row += 1;
+ foreach ($products as $product) {
+
+ $product_values = array_values($product);
+ foreach ($product_values as $product_value_index => $product_value) {
+
+ $sheet->setCellValueByColumnAndRow($product_value_index + 1, $row, $product_value);
+ }
+ $row += 1;
+ }
+ }
+
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ header('Content-Disposition: attachment;filename="Procurement Report '.$order->get_order_number().'.xlsx"');
+ header('Cache-Control: max-age=0');
+
+ $writer = new Xlsx($spreadsheet);
+ $writer->save('php://output');
+
+ exit;
+
+ }
+}
+
+Wiaas_Admin_Delivery_Process_Order::init();
diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-date.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-date.php
new file mode 100644
index 0000000..10f6ec7
--- /dev/null
+++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-delivery-date.php
@@ -0,0 +1,38 @@
+
+
+
+ Estimated delivery date:
+ "
+ onChange="onOrderEstimatedDeliveryDateChange(this.value)"/>
+
+
+
\ No newline at end of file
diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-suppliers-delivery-dates.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-suppliers-delivery-dates.php
new file mode 100644
index 0000000..93ae9e4
--- /dev/null
+++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/views/html-order-suppliers-delivery-dates.php
@@ -0,0 +1,225 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-delivery-process-ajax.php b/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-delivery-process-ajax.php
new file mode 100644
index 0000000..e4412a9
--- /dev/null
+++ b/backend/app/plugins/wiaas/includes/admin/delivery-process/wiaas-admin-delivery-process-ajax.php
@@ -0,0 +1,120 @@
+ 65000){
+ return false;
+ }
+
$cart_item = WC()->cart->get_cart_item($package_cart_item_key);
if (!$cart_item) {
@@ -309,7 +313,11 @@ class Wiaas_Cart {
* @return WC_Order_Item
*/
public static function add_order_item_meta( $order_item, $cart_item_key, $cart_item ) {
- if (wc_pb_is_bundle_container_cart_item($cart_item) && isset($cart_item['_wiaas_payment'])) {
+
+ $is_bundle_item = wc_pb_is_bundle_container_cart_item($cart_item);
+ $is_bundled_item = wc_pb_is_bundled_cart_item($cart_item);
+
+ if ($is_bundle_item && isset($cart_item['_wiaas_payment'])) {
$payment = $cart_item['_wiaas_payment'];
@@ -378,25 +386,34 @@ class Wiaas_Cart {
$order_item->add_meta_data( '_wiaas_documents', $item_documents, true );
}
- // save simple product information that needs to be avaialable later on
+ // save simple product information that needs to be available later on
// even if this data is changed or removed from product at that time
- $simple_product_meta = array();
- if(wc_pb_is_bundled_cart_item($cart_item)) {
+ if($is_bundled_item) {
- $product = $cart_item['data'];
+ $product = wc_get_product($cart_item['product_id']);
+
+ $order_item->add_meta_data('_wiaas_category', Wiaas_Product_Category::get_category($product), true);
+
+ $order_item->add_meta_data('_wiaas_manufacturer_product_no', $product->get_meta('_manufacturer_product_no'), true);
+ $order_item->add_meta_data('_wiaas_supplier_product_no', $product->get_meta('_supplier_product_no'), true);
- $simple_product_meta['_wiaas_category'] = Wiaas_Product_Category::get_category($product);
- $simple_product_meta['_wiaas_price'] = $product->get_price();
- $simple_product_meta['_wiaas_manufacturer_product_no'] = $product->get_meta('_manufacturer_product_no');
- $simple_product_meta['_wiaas_supplier_product_no'] = $product->get_meta('_supplier_product_no');
// get supplier
- if ($supplier_organization_id = Wiaas_Product_Supplier::get_supplier_organisation_id_from_product($product->get_id())) {
- $info = wiaas_get_organization_info($supplier_organization_id);
+ if ($supplier_organization_id = Wiaas_Product_Supplier::get_supplier_organisation_id_from_product($cart_item['product_id'])) {
- $simple_product_meta['_wiaas_supplier_info'] = $info;
+ $order_item->add_meta_data('_wiaas_supplier_organization_id', $supplier_organization_id, true);
}
+ // save bundled product item total cost (price x period)
+ $product_price = Wiaas_Pricing::get_product_total_cost($product);
+ $order_item->add_meta_data('_wiaas_product_price', $product_price, true);
+ }
+ // save number of days before earliest installation for bundles
+ if ($is_bundle_item) {
+ $order_item->add_meta_data(
+ '_wiaas_earliest_installation_additional_days',
+ Wiaas_Package::get_earliest_installation_additional_days($cart_item['product_id']),
+ true);
}
@@ -450,6 +467,55 @@ class Wiaas_Cart {
$shop_owner_id = absint($shop_owner_id);
$order->add_meta_data('_wiaas_commercial_lead_id', $shop_owner_id);
+
+
+ // add supplier organizations information to order
+ $suppliers_info = array();
+ $items = $order->get_items('line_item');
+
+ foreach($items as $item) {
+
+ if (! empty($item['wiaas_supplier_organization_id']) &&
+ empty($suppliers_info[$item['wiaas_supplier_organization_id']]) ) {
+
+ $supplier_organization_id = $item['wiaas_supplier_organization_id'];
+ $suppliers_info[$supplier_organization_id] = array(
+ 'id' => $supplier_organization_id,
+ 'estimated_delivery_date' => null,
+ 'confirmed_delivery_date' => null,
+ 'tracking_info' => array(),
+ );
+
+ $supplier_organization_info = wiaas_get_organization_info($supplier_organization_id);
+ foreach ($supplier_organization_info as $key => $info) {
+ $suppliers_info[$supplier_organization_id][$key] = $info;
+ }
+ }
+ }
+
+ $order->add_meta_data('_wiaas_suppliers', $suppliers_info, true);
+
+ // add additional date fields to order
+ $order->add_meta_data('_wiaas_estimated_delivery_date', null, true);
+ $order->add_meta_data('_wiaas_final_estimated_delivery_date', null, true);
+ $order->add_meta_data('_wiaas_final_confirmed_delivery_date', null, true);
+ $order->add_meta_data('_wiaas_earliest_installation_date', null, true);
+
+ // calculate number of days before earlier installation for whole order
+ $earliest_installation_additional_days = 0;
+ $items = $order->get_items('line_item');
+
+ foreach($items as $item) {
+
+ if (! empty($item['_wiaas_earliest_installation_additional_days'])) {
+
+ $additional_days = absint($item['_wiaas_earliest_installation_additional_days']);
+ $earliest_installation_additional_days = max($additional_days, $earliest_installation_additional_days);
+ }
+ }
+
+ $order->add_meta_data('_wiaas_order_additional_days_prior_installation', $earliest_installation_additional_days, true);
+
}
/**
diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php b/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php
index a0d2c1a..27cf3b5 100644
--- a/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php
+++ b/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php
@@ -22,6 +22,8 @@ class Wiaas_DB_Update {
'20191019014650' => 'wiaas_db_update_add_product_properties_ui_fields',
'20181019064450' => 'wiaas_db_update_add_bundle_properties_ui_field',
'20191020014650' => 'wiaas_create_organization_roles_capabilities',
+ '20191030162450' => 'wiaas_db_update_update_supplier_order_capabilities',
+ '20191102112451' => 'wiaas_disable_processing_order_email_delivery'
'20191030162450' => 'wiaas_db_update_update_supplier_order_capabilities',
'20191031162850' => 'update_delivery_forms'
);
diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-order.php b/backend/app/plugins/wiaas/includes/class-wiaas-order.php
index 084689c..537ac33 100644
--- a/backend/app/plugins/wiaas/includes/class-wiaas-order.php
+++ b/backend/app/plugins/wiaas/includes/class-wiaas-order.php
@@ -18,6 +18,7 @@ class Wiaas_Order {
public static function init() {
require_once dirname( __FILE__ ) . '/order/class-wiaas-order-project.php';
+ require_once dirname( __FILE__ ) . '/order/class-wiaas-procurement-order.php';
require_once dirname( __FILE__ ) . '/order/wiaas-order-functions.php';
add_filter('woocommerce_register_post_type_shop_order', array(__CLASS__, 'manage_order_settings'));
@@ -45,6 +46,164 @@ class Wiaas_Order {
return "1000000$number";
}
+ public static function get_additional_days_prior_installation($order_id){
+ $order = wc_get_order($order_id);
+ return $order->get_meta('_wiaas_order_additional_days_prior_installation');
+ }
+
+ public static function add_additional_tracking_info($order_id, $supplier_id){
+ $suppliers = self::get_suppliers($order_id);
+ foreach($suppliers as $key => $supplier){
+ if ($supplier['id'] === $supplier_id){
+ $suppliers[$key]['tracking_info'][] = array(
+ 'number' => '',
+ 'url' => ''
+ );
+
+ $order = wc_get_order($order_id);
+ $order->update_meta_data('_wiaas_suppliers', $suppliers);
+ $order->save_meta_data();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static function save_tracking_info($order_id, $supplier_id, $tracking_index, $tracking_num, $tracking_url){
+ $suppliers = self::get_suppliers($order_id);
+ foreach($suppliers as $key => $supplier){
+ if ($supplier['id'] === $supplier_id){
+ $suppliers[$key]['tracking_info'][$tracking_index]['number'] = $tracking_num;
+ $suppliers[$key]['tracking_info'][$tracking_index]['url'] = $tracking_url;
+
+
+ $order = wc_get_order($order_id);
+ $order->update_meta_data('_wiaas_suppliers', $suppliers);
+ $order->save_meta_data();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static function delete_tracking_info($order_id, $supplier_id, $tracking_index){
+ $suppliers = self::get_suppliers($order_id);
+ foreach($suppliers as $key => $supplier){
+ if ($supplier['id'] === $supplier_id){
+ unset($suppliers[$key]['tracking_info'][$tracking_index]);
+
+ $order = wc_get_order($order_id);
+ $order->update_meta_data('_wiaas_suppliers', $suppliers);
+ $order->save_meta_data();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static function save_estimated_date($order_id, $supplier_id, $date){
+ $suppliers = wiaas_get_order_delivery_suppliers($order_id);
+ $updated = false;
+ foreach($suppliers as $key => $supplier){
+ if ($supplier['id'] === $supplier_id){
+ $suppliers[$key]['estimated_date'] = $date;
+ $updated = true;
+ }
+ }
+
+ if (!$updated){
+ return false;
+ }
+
+ $order = wc_get_order($order_id);
+
+ $order->update_meta_data('_wiaas_suppliers', $suppliers);
+ self::_update_max_and_earliest_dates($order, $suppliers);
+
+ $order->save_meta_data();
+ return true;
+ }
+
+ public static function save_confirmed_date($order_id, $supplier_id, $date){
+
+ $suppliers = wiaas_get_order_delivery_suppliers($order_id);
+ $updated = false;
+
+ foreach($suppliers as $key => $supplier){
+ if ($supplier['id'] === $supplier_id){
+ $suppliers[$key]['confirmed_date'] = $date;
+ $updated = true;
+ if (!$suppliers[$key]['estimated_date']){
+ $suppliers[$key]['estimated_date'] = $date;
+ }
+ }
+ }
+
+ if (!$updated){
+ return false;
+ }
+
+ $order = wc_get_order($order_id);
+
+ $order->update_meta_data('_wiaas_suppliers', $suppliers);
+ self::_update_max_and_earliest_dates($order, $suppliers);
+
+ $order->save_meta_data();
+ return true;
+ }
+
+ public static function get_order_estimated_date($order_id){
+ $order = wc_get_order($order_id);
+ if (!$order){
+ return NULL;
+ }
+
+ return $order->get_meta('_wiaas_order_estimated_delivery_date') ?: NULL;
+ }
+
+ public static function save_order_estimated_date($order_id, $date){
+ return update_post_meta($order_id, '_wiaas_order_estimated_delivery_date', $date);
+ }
+
+ public static function get_final_estimated_date($order_id){
+ $order = wc_get_order($order_id);
+ if (!$order){
+ return 0;
+ }
+
+ return $order->get_meta('_wiaas_final_estimated_delivery_date') ?: 0;
+ }
+
+ public static function get_final_confirmed_date($order_id){
+ $order = wc_get_order($order_id);
+ if (!$order){
+ return 0;
+ }
+
+ return $order->get_meta('_wiaas_final_confirmed_delivery_date') ?: 0;
+ }
+
+ public static function get_earliest_installation_date($order_id){
+ $order = wc_get_order($order_id);
+ if (!$order){
+ return 0;
+ }
+
+ return $order->get_meta('_wiaas_earliest_installation_date') ?: 0;
+ }
+
+
+ /**
+ * Get suppliers related to order
+ */
+ public static function get_suppliers($order_id){
+ $order = wc_get_order($order_id);
+ return $order->get_meta('_wiaas_suppliers');
+ }
+
/**
* Update `shop_order` post type settings before creation to enable better order management for wiaas
*
@@ -191,12 +350,53 @@ class Wiaas_Order {
public static function get_order_tender($order_id) {
return get_post_meta($order_id, '_wiaas_tender', true);
- }
+ }
/**
* PRIVATE
*/
+ private static function _update_max_and_earliest_dates($order, $suppliers){
+ $max_estimated_date = 0;
+ $max_confirmed_date = 0;
+ $earliest_installation_date = 0;
+ $missing_estimated = false;
+
+ foreach($suppliers as $supplier) {
+
+ error_log($supplier['confirmed_date']);
+ error_log($supplier['estimated_date']);
+
+ if (! empty($supplier['confirmed_date']) ) {
+
+ $max_confirmed_date = max($max_confirmed_date, $supplier['confirmed_date']);
+ } else {
+
+ $missing_confirmed = true;
+ }
+
+ if (! empty($supplier['estimated_date']) ) {
+
+ $max_estimated_date = max($max_estimated_date, $supplier['estimated_date']);
+
+ } else {
+
+ $missing_estimated = true;
+ $earliest_installation_date = 0;
+ }
+ }
+
+ if (! $missing_estimated) {
+
+ $earliest_installation_date = max($max_estimated_date, $max_confirmed_date);
+ $earliest_installation_date = strtotime('+' . self::get_additional_days_prior_installation($order->id) . ' days', $earliest_installation_date);
+ }
+
+ $order->update_meta_data('_wiaas_final_confirmed_delivery_date', $max_confirmed_date);
+ $order->update_meta_data('_wiaas_final_estimated_delivery_date', $max_estimated_date);
+ $order->update_meta_data('_wiaas_earliest_installation_date', $earliest_installation_date);
+ }
+
/**
* Append specific wiaas order details, like reference
* @param $data
diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-package.php b/backend/app/plugins/wiaas/includes/class-wiaas-package.php
index 9800711..e1527b0 100644
--- a/backend/app/plugins/wiaas/includes/class-wiaas-package.php
+++ b/backend/app/plugins/wiaas/includes/class-wiaas-package.php
@@ -48,6 +48,10 @@ class Wiaas_Package {
return $response;
}
+ public static function get_earliest_installation_additional_days($package_id){
+ return get_post_meta($package_id, 'additional_days_prior_earliest_installation', true);
+ }
+
/**
* Append package documents
* @param $data
diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-product.php b/backend/app/plugins/wiaas/includes/class-wiaas-product.php
index 9bddd4a..73f5a82 100644
--- a/backend/app/plugins/wiaas/includes/class-wiaas-product.php
+++ b/backend/app/plugins/wiaas/includes/class-wiaas-product.php
@@ -70,6 +70,10 @@ class Wiaas_Product {
return $args;
}
+
+ public static function get_supplier_id($product_id){
+ return wp_get_post_terms($product_id, 'supplier', array('fields' => 'ids'))[0];
+ }
}
Wiaas_Product::init();
\ No newline at end of file
diff --git a/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-bundle-properties.json b/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-bundle-properties.json
index 6eaf16d..d5de4dc 100644
--- a/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-bundle-properties.json
+++ b/backend/app/plugins/wiaas/includes/db-updates/data/wiaas-ui-field-bundle-properties.json
@@ -46,6 +46,27 @@
"load_terms": 1,
"return_format": "id",
"multiple": 0
+ },
+ {
+ "key": "field_5bdb1512ab14f",
+ "label": "Additional days prior earliest installation",
+ "name": "additional_days_prior_earliest_installation",
+ "type": "number",
+ "instructions": "",
+ "required": 0,
+ "conditional_logic": 0,
+ "wrapper": {
+ "width": "",
+ "class": "",
+ "id": ""
+ },
+ "default_value": 5,
+ "placeholder": "",
+ "prepend": "",
+ "append": "",
+ "min": 0,
+ "max": "",
+ "step": ""
}
],
"location": [
diff --git a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php
index ebc699a..9e23a7a 100644
--- a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php
+++ b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-general.php
@@ -78,6 +78,15 @@ function wiaas_create_organization_roles_capabilities() {
}
}
+function wiaas_disable_processing_order_email_delivery() {
+ update_option( 'woocommerce_customer_processing_order_settings', array(
+ 'enabled' => 'no',
+ 'subject' => '',
+ 'heading' => '',
+ 'mail_type' => 'html'
+ ) );
+}
+
function update_delivery_forms() {
diff --git a/backend/app/plugins/wiaas/includes/order/class-wiaas-procurement-order.php b/backend/app/plugins/wiaas/includes/order/class-wiaas-procurement-order.php
new file mode 100644
index 0000000..d48c639
--- /dev/null
+++ b/backend/app/plugins/wiaas/includes/order/class-wiaas-procurement-order.php
@@ -0,0 +1,98 @@
+get_customer_id();
+ $organization_id = wiaas_get_user_organization_id($customer_user_id);
+ $customer_organization_info = wiaas_get_organization_info($organization_id);
+
+ $info = array(
+ 'number' => $order->get_order_number(),
+ 'project_number' => 'SE' . $order->get_order_number(),
+ 'reference' => $order->get_meta('_wiaas_reference'),
+
+ 'vat_code' => ! empty($customer_organization_info) ? $customer_organization_info['vat_code'] : '',
+ 'customer_name' => ! empty($customer_organization_info) ? $customer_organization_info['name'] : '',
+
+ 'delivery_address' => $order->get_shipping_address_1() . ',' .
+ $order->get_shipping_city() . ',' .
+ $order->get_shipping_country() . ',' .
+ $order->get_shipping_postcode(),
+ 'delivery_full_name' => $order->get_formatted_shipping_full_name(),
+
+ 'billing_address' => $order->get_billing_address_1() . ',' .
+ $order->get_billing_city() . ',' .
+ $order->get_billing_country() . ',' .
+ $order->get_billing_postcode(),
+ 'billing_full_name' => $order->get_formatted_billing_full_name(),
+ 'billing_email' => $order->get_billing_email()
+ );
+
+ $objPHPExcel->getProperties()->setCreator("RICOH")
+ ->setLastModifiedBy("Ricoh Dash")
+ ->setTitle("Order Procurement Report")
+ ->setSubject("Order Procurement Report")
+ ->setDescription("Order Procurement Report")
+ ->setKeywords("office 2007 openxml php order procurement")
+ ->setCategory("Procurement report file");
+
+
+ $objPHPExcel->setActiveSheetIndex(0)
+ ->setCellValue('A1', 'Customer details')
+
+ ->setCellValue('A2', 'Name')
+ ->setCellValue('A3', 'Invoice address')
+ ->setCellValue('A4', 'Invoice full name')
+ ->setCellValue('A5', 'Invoice email')
+ ->setCellValue('A6', 'VAT Number')
+
+ ->setCellValue('B2', $info['customer_name'])
+ ->setCellValue('B3', $info['billing_address'])
+ ->setCellValue('B4', $info['billing_full_name'])
+ ->setCellValue('B5', $info['billing_email'])
+ ->setCellValue('B6', $info['vat_code']);
+ $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
+
+ $objPHPExcel->setActiveSheetIndex(0)
+ ->setCellValue('A9', 'OrderDetails')
+
+ ->setCellValue('A10', 'Order number')
+ ->setCellValue('A11', 'Project number')
+ ->setCellValue('A12', 'Delivery address')
+ ->setCellValue('A13', 'Delivery full name')
+ ->setCellValue('A14', 'Reference')
+
+ ->setCellValue('B10', $info['number'])
+ ->setCellValue('B11', $info['project_number'])
+ ->setCellValue('B12', $info['delivery_address'])
+ ->setCellValue('B13', $info['delivery_full_name'])
+ ->setCellValue('B14', $info['reference']);
+ $objPHPExcel->getActiveSheet()->getStyle('A10')->getFont()->setBold(true);
+
+ $objPHPExcel->getActiveSheet()->setTitle('Order procurement');
+ $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
+ header('Content-Disposition: attachment;filename="procurement_report_'.$info['orderNumber'].'.xlsx"');
+ $objWriter->save('php://output');
+ }
+}
+
+Wiaas_Procurement_Order::init();
diff --git a/backend/app/plugins/wiaas/includes/order/wiaas-order-functions.php b/backend/app/plugins/wiaas/includes/order/wiaas-order-functions.php
index 0787060..0d71cbc 100644
--- a/backend/app/plugins/wiaas/includes/order/wiaas-order-functions.php
+++ b/backend/app/plugins/wiaas/includes/order/wiaas-order-functions.php
@@ -27,4 +27,88 @@ function wiaas_get_order_standard_bundle_items($order) {
}
return $standard_bundle_items;
+}
+
+/**
+ * Retrieve order summary data for procurement order for suppliers
+ *
+ * @param int $order_id
+ *
+ * @return array
+ */
+function wiaas_get_order_procurement_info($order_id) {
+
+ $order = wc_get_order($order_id);
+
+ $order_items = $order->get_items();
+
+ $order_suppliers_info = $order->get_meta('_wiaas_suppliers');
+
+ $data = array();
+
+ foreach ($order_items as $order_item_id => $order_item) {
+
+ $category = $order_item['_wiaas_category'];
+ $supplier_organization_id = $order_item['wiaas_supplier_organization_id'];
+ $supplier_info = $order_suppliers_info[$supplier_organization_id];
+
+ if (empty($category)) {
+
+ continue;
+ }
+
+ $data[$category] ?: array();
+
+ // get price and quantity
+ $single_product_item_cost = floatval($order_item['wiaas_product_price']);
+
+ $quantity = absint($order_item['quantity']);
+ $total_price = $quantity * $single_product_item_cost;
+
+ $data[$category][] = array(
+ 'Name' => $order_item->get_name(),
+ 'Category' => ucfirst(strtolower($category)),
+ 'Manufacturer Product No' => $order_item['wiaas_manufacturer_product_no'],
+ 'Supplier Product No' => $order_item['wiaas_supplier_product_no'],
+ 'Units' => $quantity,
+ 'Price' => $total_price,
+ 'Supplier Company' => $supplier_info['name'],
+ 'Supplier VAT' => $supplier_info['vat_code'],
+ 'Supplier Phone' => $supplier_info['phone'],
+ 'Supplier Email' => $supplier_info['email'],
+ );
+ }
+
+ return $data;
+}
+
+/**
+ * Retrieve delivery supplier organizations for order which does not include installation providers
+ *
+ * @param int $order_id
+ *
+ * @return array
+ */
+function wiaas_get_order_delivery_suppliers($order_id) {
+
+ $order = wc_get_order($order_id);
+
+ $supplier_organizations = $order->get_meta('_wiaas_suppliers', true);
+
+ $delivery_supplier_organizations = array();
+
+ $order_items = $order->get_items();
+
+ foreach ($order_items as $order_item_id => $order_item) {
+
+ $supplier_organization_id = $order_item['wiaas_supplier_organization_id'];
+
+ if (! empty($supplier_organization_id) && $order_item['wiaas_category'] !== 'installation' &&
+ empty($delivery_supplier_organizations[$supplier_organization_id])) {
+
+ $delivery_supplier_organizations[$supplier_organization_id] = $supplier_organizations[$supplier_organization_id];
+ }
+ }
+
+ return $delivery_supplier_organizations;
}
\ No newline at end of file
diff --git a/backend/app/plugins/wiaas/includes/user/wiaas-organization-functions.php b/backend/app/plugins/wiaas/includes/user/wiaas-organization-functions.php
index e68884f..041d04d 100644
--- a/backend/app/plugins/wiaas/includes/user/wiaas-organization-functions.php
+++ b/backend/app/plugins/wiaas/includes/user/wiaas-organization-functions.php
@@ -132,8 +132,8 @@ function wiaas_get_organization_info($organization_id) {
return array(
'name' => $organization->name,
'description' => $organization->description,
- 'vat_code' => get_term_meta($organization_id, '_wiaas_organization_vat'),
- 'phone' => get_term_meta($organization_id, '_wiaas_organization_phone'),
+ 'vat_code' => get_term_meta($organization_id, '_wiaas_organization_vat', true),
+ 'phone' => get_term_meta($organization_id, '_wiaas_organization_phone', true),
'email' => $email
);
}
diff --git a/backend/composer.json b/backend/composer.json
index 1d32732..dcb40e3 100644
--- a/backend/composer.json
+++ b/backend/composer.json
@@ -49,6 +49,7 @@
"johnpbloch/wordpress": "4.9.7",
"oscarotero/env": "1.1.0",
"roots/wp-password-bcrypt": "1.0.0",
+ "phpoffice/phpspreadsheet": "1.5",
"woocommerce/woocommerce": "3.5.0",
"3rdparty/woocommerce-product-bundles": "*",
diff --git a/backend/composer.lock b/backend/composer.lock
index 8cc35ab..3afb615 100644
--- a/backend/composer.lock
+++ b/backend/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "46d983092d336b15b357f8569468977c",
+ "content-hash": "6e6e270e7e619ff0ceaa12a0f586d517",
"packages": [
{
"name": "3rdparty/gravityflow",
@@ -285,6 +285,101 @@
],
"time": "2018-01-29T14:49:29+00:00"
},
+ {
+ "name": "markbaker/complex",
+ "version": "1.4.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/MarkBaker/PHPComplex.git",
+ "reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
+ "reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.6.0|^7.0.0"
+ },
+ "require-dev": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
+ "phpcompatibility/php-compatibility": "^8.0",
+ "phpdocumentor/phpdocumentor": "2.*",
+ "phploc/phploc": "2.*",
+ "phpmd/phpmd": "2.*",
+ "phpunit/phpunit": "^4.8.35|^5.4.0",
+ "sebastian/phpcpd": "2.*",
+ "squizlabs/php_codesniffer": "^3.3.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Complex\\": "classes/src/"
+ },
+ "files": [
+ "classes/src/functions/abs.php",
+ "classes/src/functions/acos.php",
+ "classes/src/functions/acosh.php",
+ "classes/src/functions/acot.php",
+ "classes/src/functions/acoth.php",
+ "classes/src/functions/acsc.php",
+ "classes/src/functions/acsch.php",
+ "classes/src/functions/argument.php",
+ "classes/src/functions/asec.php",
+ "classes/src/functions/asech.php",
+ "classes/src/functions/asin.php",
+ "classes/src/functions/asinh.php",
+ "classes/src/functions/atan.php",
+ "classes/src/functions/atanh.php",
+ "classes/src/functions/conjugate.php",
+ "classes/src/functions/cos.php",
+ "classes/src/functions/cosh.php",
+ "classes/src/functions/cot.php",
+ "classes/src/functions/coth.php",
+ "classes/src/functions/csc.php",
+ "classes/src/functions/csch.php",
+ "classes/src/functions/exp.php",
+ "classes/src/functions/inverse.php",
+ "classes/src/functions/ln.php",
+ "classes/src/functions/log2.php",
+ "classes/src/functions/log10.php",
+ "classes/src/functions/negative.php",
+ "classes/src/functions/pow.php",
+ "classes/src/functions/rho.php",
+ "classes/src/functions/sec.php",
+ "classes/src/functions/sech.php",
+ "classes/src/functions/sin.php",
+ "classes/src/functions/sinh.php",
+ "classes/src/functions/sqrt.php",
+ "classes/src/functions/tan.php",
+ "classes/src/functions/tanh.php",
+ "classes/src/functions/theta.php",
+ "classes/src/operations/add.php",
+ "classes/src/operations/subtract.php",
+ "classes/src/operations/multiply.php",
+ "classes/src/operations/divideby.php",
+ "classes/src/operations/divideinto.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Mark Baker",
+ "email": "mark@lange.demon.co.uk"
+ }
+ ],
+ "description": "PHP Class for working with complex numbers",
+ "homepage": "https://github.com/MarkBaker/PHPComplex",
+ "keywords": [
+ "complex",
+ "mathematics"
+ ],
+ "time": "2018-10-13T23:28:42+00:00"
+ },
{
"name": "oscarotero/env",
"version": "v1.1.0",
@@ -327,6 +422,141 @@
],
"time": "2017-07-17T20:41:59+00:00"
},
+ {
+ "name": "phpoffice/phpspreadsheet",
+ "version": "1.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
+ "reference": "2dfd06c59825914a1a325f2a2ed13634b9d8c411"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/2dfd06c59825914a1a325f2a2ed13634b9d8c411",
+ "reference": "2dfd06c59825914a1a325f2a2ed13634b9d8c411",
+ "shasum": ""
+ },
+ "require": {
+ "ext-ctype": "*",
+ "ext-dom": "*",
+ "ext-gd": "*",
+ "ext-iconv": "*",
+ "ext-libxml": "*",
+ "ext-mbstring": "*",
+ "ext-simplexml": "*",
+ "ext-xml": "*",
+ "ext-xmlreader": "*",
+ "ext-xmlwriter": "*",
+ "ext-zip": "*",
+ "ext-zlib": "*",
+ "markbaker/complex": "^1.4.1",
+ "php": "^5.6|^7.0",
+ "psr/simple-cache": "^1.0"
+ },
+ "require-dev": {
+ "dompdf/dompdf": "^0.8.0",
+ "friendsofphp/php-cs-fixer": "@stable",
+ "jpgraph/jpgraph": "^4.0",
+ "mpdf/mpdf": "^7.0.0",
+ "phpunit/phpunit": "^5.7",
+ "squizlabs/php_codesniffer": "^3.3",
+ "tecnickcom/tcpdf": "^6.2"
+ },
+ "suggest": {
+ "dompdf/dompdf": "Option for rendering PDF with PDF Writer",
+ "jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
+ "mpdf/mpdf": "Option for rendering PDF with PDF Writer",
+ "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-2.1-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Maarten Balliauw",
+ "homepage": "http://blog.maartenballiauw.be"
+ },
+ {
+ "name": "Erik Tilt"
+ },
+ {
+ "name": "Franck Lefevre",
+ "homepage": "http://rootslabs.net"
+ },
+ {
+ "name": "Mark Baker",
+ "homepage": "http://markbakeruk.net"
+ }
+ ],
+ "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
+ "homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
+ "keywords": [
+ "OpenXML",
+ "excel",
+ "gnumeric",
+ "ods",
+ "php",
+ "spreadsheet",
+ "xls",
+ "xlsx"
+ ],
+ "time": "2018-10-21T10:04:54+00:00"
+ },
+ {
+ "name": "psr/simple-cache",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/simple-cache.git",
+ "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
+ "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\SimpleCache\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interfaces for simple caching",
+ "keywords": [
+ "cache",
+ "caching",
+ "psr",
+ "psr-16",
+ "simple-cache"
+ ],
+ "time": "2017-10-23T01:57:42+00:00"
+ },
{
"name": "roots/wp-password-bcrypt",
"version": "1.0.0",
diff --git a/frontend/src/constants/cartConstants.js b/frontend/src/constants/cartConstants.js
index 2a3acb8..b4b6801 100644
--- a/frontend/src/constants/cartConstants.js
+++ b/frontend/src/constants/cartConstants.js
@@ -65,7 +65,7 @@ export const cartMessages = {
QUANTITY_UPDATED: "Quantity has been updated for the package!",
INVALID_PACKAGE_FOR_REMOVE: "This package is not available in your cart! In case this error persists contact Co-Market!",
PACKAGE_REMOVED_FROM_CART: "The package has been removed from the cart!",
- INVALID_QUANTITY: "The quantity can be a number between 1 and 100!",
+ INVALID_QUANTITY: "The quantity can be a number between 1 and 65000!",
CART_EMPTY: "You must have at least one package in the cart!",
NO_DELIVERY_ADDRESS: "No delivery address was added! Please fill the necessary info",
INCOMPLETE_DELIVERY_ADDRESS: "Incomplete delivery address. Please review!",
diff --git a/frontend/src/constants/coMarketConstants.js b/frontend/src/constants/coMarketConstants.js
index cb7fccc..55bdf3f 100644
--- a/frontend/src/constants/coMarketConstants.js
+++ b/frontend/src/constants/coMarketConstants.js
@@ -32,7 +32,7 @@ export const coMarketMessages = {
QUANTITY_UPDATED: "Quantity has been updated for the package!",
INVALID_PACKAGE_FOR_REMOVE: "This package is not available in your cart! In case this error persists contact the Co-Market!",
PACKAGE_REMOVED_FROM_CART: "The package has been removed from the cart!",
- INVALID_QUANTITY: "The quantity can be a number between 1 and 100!",
+ INVALID_QUANTITY: "The quantity can be a number between 1 and 65000!",
CART_EMPTY: "You must have at least one package in the cart!",
NO_DELIVERY_ADDRESS: "No delivery address was added! Please fill the necessary info",
INCOMPLETE_DELIVERY_ADDRESS: "Incomplete delivery address. Please review!",
diff --git a/frontend/src/containers/cart/components/CartItem.jsx b/frontend/src/containers/cart/components/CartItem.jsx
index 9618061..b0736b7 100644
--- a/frontend/src/containers/cart/components/CartItem.jsx
+++ b/frontend/src/containers/cart/components/CartItem.jsx
@@ -35,13 +35,13 @@ class CartItem extends Component {
}
isQuantityValid(quantity) {
- return quantity > 0 && quantity <= 100;
+ return quantity > 0 && quantity <= 65000;
}
updateQuantity(cartItem, quantity) {
if(quantity) {
- this.setState({itemQuantity: quantity});
if(this.isQuantityValid(quantity)) {
+ this.setState({itemQuantity: quantity});
this.sumPrices(cartItem, quantity);
this.props.dispatch(updateQuantity(cartItem, quantity));
} else {