Plugin Directory

Changeset 2560157


Ignore:
Timestamp:
07/07/2021 04:52:59 PM (5 years ago)
Author:
phcwordpress
Message:

upd 20210707

Location:
drivefx-woocommerce/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • drivefx-woocommerce/trunk/PHCLibrary/classes/settings.php

    r2556290 r2560157  
    2424    public $warehouse;
    2525    public $sendInvoice;
     26    public $typeOfReport;
    2627 }
  • drivefx-woocommerce/trunk/PHCLibrary/utils.php

    r2558913 r2560157  
    252252    *                  --- Get Report For Print ---                    *
    253253    ********************************************************************/
    254     /** Header to create Query of a limited (20) internal document **/
     254   
    255255    public function paramsGetReportForPrint($ch, $credentials){
    256256        $this->url = $credentials->backendUrl."/REST/reportws/getReportsForPrint";
  • drivefx-woocommerce/trunk/class.DriveFxWoocommerce.php

    r2558913 r2560157  
    3232                'createInvoice'     => array('label' => 'Create Orders and Invoices',                 'type' => 'checkbox',      'required' => false, 'checkboxDescription' => 'Create invoices for orders that come in, otherwise only the client is created (recommended).', 'notice' => ''),
    3333                'sendInvoice'       => array('label' => 'Send Invoice',                               'type' => 'checkbox',      'required' => false, 'checkboxDescription' => 'Send the client an e-mail with the order invoice attached', 'notice' => ''),
     34                'typeOfReport'      => array('label' => 'Type of Report',                             'type' => 'select',        'required' => false, 'checkboxDescription' => 'Choose the type of report for invoice documents', 'notice' => ''),
    3435                'emailBody'         => array('label' => 'E-mail body content',                        'type' => 'text',          'required' => false, 'descr' => 'Enter the text to be attached to the e-mails sent to the client.', 'notice' => ''),
    35                 'typeOfInvoice'     => array('label' => 'Type of Invoice Document (PT)',              'type' => 'select',        'required' => false, 'checkboxDescription' => 'Choose the type of invoice document', 'notice' => ''),
    36                 'typeOf_EU_Invoice' => array('label' => 'Type of Invoice Document (EU)',              'type' => 'select',        'required' => false, 'checkboxDescription' => 'Choose the type of invoice document', 'notice' => ''),
     36                'typeOfInvoice'     => array('label' => 'Type of Invoice Document (PT)',              'type' => 'select',        'required' => false, 'checkboxDescription' => 'Choose the type of invoice document (PT)', 'notice' => ''),
     37                'typeOf_EU_Invoice' => array('label' => 'Type of Invoice Document (EU)',              'type' => 'select',        'required' => false, 'checkboxDescription' => 'Choose the type of invoice document (EU)', 'notice' => ''),
    3738                'toSignInvoice'     => array('label' => 'Sign Invoice',                               'type' => 'checkbox',      'required' => false, 'checkboxDescription' => 'Sign Invoice document after its creation.', 'notice' => ''),
    3839                'fieldNif'          => array('label' => 'NIF Field in Woocommerce',                   'type' => 'select',        'required' => false, 'checkboxDescription' => 'Choose the nif field of woocommerce', 'notice' => ''),
     
    10341035                    if(isset($settings['backend']['typeOfInvoice']) && $settings['backend']['createInvoice'] == 'on' && $settings['backend']['typeOfInvoice'] > 0 && isset($settings['backend']['sendInvoice'])){
    10351036
    1036                         ### [Query] - Obtain type invoices
     1037                        ### [Query] - Obtain type of report
    10371038                        $response = $this->utils_services->paramsGetReportForPrint($ch, $credentials);
    10381039                        //$this->logs->writeFileLog('ReportPrint response:', $response);
     
    10471048                            $this->messagesError(" in configuration of send email with FT! Message from Backend: " . $response['messages'][0]['messageCodeLocale']);
    10481049                        } else {
     1050
     1051                            ### [Field] - Create options of reports dropdownlist list
     1052                            $i = 0;
     1053                            $_SESSION['typeOfReport'] = '';
     1054
     1055                            foreach ($response['result'] as $key => $value){
     1056                                if($settings['backend']['typeOfReport'] == $value['repstamp']){
     1057                                    $selected_dropdown = 'selected';
     1058                                } else {
     1059                                    $selected_dropdown = '';
     1060                                }
     1061
     1062                                $_SESSION['typeOfReport'] .= "<option value=" . $value['repstamp'] . " " . $selected_dropdown . ">" . $value['reportname'] ."</option><br>";
     1063                                ++$i;
     1064                            }
     1065
    10491066                            //Verify if exists template as default
    10501067                            $i = 0;
     
    16141631            # Verify if are selected type of internal document and send invoice checkbox
    16151632            if(isset($settings['backend']['typeOfInvoice']) && $settings['backend']['createInvoice'] == 'on' &&
    1616                     $settings['backend']['typeOfInvoice'] > 0 && isset($settings['backend']['sendInvoice'])){
    1617 
    1618                 //Obtain reports for print
    1619                 $response = $this->utils_services->paramsGetReportForPrint($ch, $credentials);
    1620 
    1621                 //$this->logs->writeFileLog('paramsGetReportForPrint:', $response);
    1622 
    1623                 if (curl_error($ch)) {
    1624                     $this->logs->writeFileLog('addSimpleFT17', $ch);
    1625                 } else if(empty($response)){
    1626                     $this->logs->writeFileLog('addSimpleFT17', 'EMPTY RESPONSE');
    1627                 } else if(isset($response['messages'][0]['messageCodeLocale'])){
    1628                     $this->logs->writeFileLog('addSimpleFT17', $response['messages'][0]['messageCodeLocale']);
     1633                     $settings['backend']['typeOfInvoice'] > 0 && isset($settings['backend']['sendInvoice'])){
     1634
     1635                $sendEmail = false;
     1636
     1637                if (isset($settings['backend']['typeOfReport']) && !empty($settings['backend']['typeOfReport'])){
     1638
     1639                    //Use the report that was selected by user
     1640                    $_SESSION['repstamp'] = $settings['backend']['typeOfReport'];
     1641                    $sendEmail = true;
     1642
    16291643                } else {
    1630                     //Verify if exists template as default
    1631                     $i = 0;
    1632                     $count = count($response['result']);
    1633                     $sendEmail = false;
    1634                     while ($i < $count) {
    1635                         foreach ($response['result'][$i] as $key => $value){
    1636                             if($key == 'enabled' && $value == 1){
    1637                                 $sendEmail = true;
    1638                                 $_SESSION['repstamp'] = $response['result'][$i]['repstamp'];
    1639                                 break;
    1640                             }
    1641                         }
    1642                         ++$i;
    1643                     }
    1644                     #If exists template as default
    1645                     if($sendEmail == true){
    1646                         //Obtain client
    1647                         /* $response = $this->utils_services->filterItem_Query($ch, $credentials, 'Cl', 'no', $_SESSION['numberClient']);
    1648 
    1649                         $this->logs->writeFileLog('custom_by_no:', $response);
     1644                    ### [Query] - Obtain reports for print
     1645                    $response = $this->utils_services->paramsGetReportForPrint($ch, $credentials);
     1646                    //$this->logs->writeFileLog('paramsGetReportForPrint:', $response);
     1647
     1648                    if (curl_error($ch)) {
     1649                        $this->logs->writeFileLog('addSimpleFT17', $ch);
     1650                    } else if(empty($response)){
     1651                        $this->logs->writeFileLog('addSimpleFT17', 'EMPTY RESPONSE');
     1652                    } else if(isset($response['messages'][0]['messageCodeLocale'])){
     1653                        $this->logs->writeFileLog('addSimpleFT17', $response['messages'][0]['messageCodeLocale']);
     1654                    } else {
     1655                        //Verify if exists templates and take the enable one
     1656                        $i = 0;
     1657                        $count = count($response['result']);
     1658                        while ($i < $count) {
     1659                            foreach ($response['result'][$i] as $key => $value){
     1660                                if($key == 'enabled' && $value == 1){
     1661                                    $sendEmail = true;
     1662                                    $_SESSION['repstamp'] = $response['result'][$i]['repstamp'];
     1663                                    break;
     1664                                }
     1665                            }
     1666                            ++$i;
     1667                        }
     1668                    }
     1669                }
     1670
     1671                #If exists template as default
     1672                if($sendEmail == true){
     1673
     1674                    if($dataPack->customer->email != ''){
     1675                        //Email To
     1676                        $_SESSION['emailClient'] = $dataPack->customer->email;
     1677                        //Email From
     1678                        $infoAdmin = $this->get_settingsAdmin();
     1679                        $emailAdmin = $infoAdmin[3]['default'];
     1680                        ###
     1681                        $body = $settings['backend']['emailBody'];
     1682
     1683                        //Send FT to email selected
     1684                        $response = $this->utils_services->paramsSendReportEmail(
     1685                                                            $ch, $credentials, $_SESSION['repstamp'],
     1686                                                            $_SESSION['ftstamp'], $_SESSION['emailClient'],
     1687                                                            $emailAdmin, $settings['backend']['typeOfInvoice'], '', $body);
     1688
     1689                        // $this->logs->writeFileLog('paramsSendReportEmail:', $response);
    16501690
    16511691                        if (curl_error($ch)) {
    1652                             $this->logs->writeFileLog('addSimpleFT18', $ch);
     1692                            $this->logs->writeFileLog('addSimpleFT19', $ch);
    16531693                        } else if(empty($response)){
    1654                             $this->logs->writeFileLog('addSimpleFT18', 'EMPTY RESPONSE');
     1694                            $this->logs->writeFileLog('addSimpleFT19', 'EMPTY RESPONSE');
    16551695                        } else if(isset($response['messages'][0]['messageCodeLocale'])){
    1656                             $this->logs->writeFileLog('addSimpleFT18', $response['messages'][0]['messageCodeLocale']);
    1657                         } else { */
    1658                             //if($response['result'][0]['email'] != ''){
    1659                             if($dataPack->customer->email != ''){
    1660                                 //Email To
    1661                                 //$_SESSION['emailClient'] = $response['result'][0]['email'];
    1662                                 $_SESSION['emailClient'] = $dataPack->customer->email;
    1663                                 //Email From
    1664                                 $infoAdmin = $this->get_settingsAdmin();
    1665                                 $emailAdmin = $infoAdmin[3]['default'];
    1666                                 ###
    1667                                 $body = $settings['backend']['emailBody'];
    1668 
    1669                                 //Send FT to email selected
    1670                                 $response = $this->utils_services->paramsSendReportEmail(
    1671                                                                     $ch, $credentials, $_SESSION['repstamp'],
    1672                                                                     $_SESSION['ftstamp'], $_SESSION['emailClient'],
    1673                                                                     $emailAdmin, $settings['backend']['typeOfInvoice'], '', $body);
    1674 
    1675                                 //$this->logs->writeFileLog('paramsSendReportEmail:', $response);
    1676 
    1677                                 if (curl_error($ch)) {
    1678                                     $this->logs->writeFileLog('addSimpleFT19', $ch);
    1679                                 } else if(empty($response)){
    1680                                     $this->logs->writeFileLog('addSimpleFT19', 'EMPTY RESPONSE');
    1681                                 } else if(isset($response['messages'][0]['messageCodeLocale'])){
    1682                                     $this->logs->writeFileLog('addSimpleFT19', $response['messages'][0]['messageCodeLocale']);
    1683                                 } else {
    1684                                     $this->logs->writeFileLog('Info:', 'Email sended');
    1685                                 }
    1686                             }
    1687                         }
    1688                     //}
     1696                            $this->logs->writeFileLog('addSimpleFT19', $response['messages'][0]['messageCodeLocale']);
     1697                        } else {
     1698                            $this->logs->writeFileLog('Info:', 'Email sended');
     1699                        }
     1700                    }
    16891701                }
    16901702            }
  • drivefx-woocommerce/trunk/settings/backend.php

    r2556290 r2560157  
    164164              <span><?php echo $opts['checkboxDescription'] ?></span>
    165165              <p class="description"><?php echo $opts['descr'] ?></p>
     166            </td>
     167          </tr>
     168          <?php } break;
     169          case 'typeOfReport':
     170            if($settings['backend']['createInvoice'] != '' && $settings['backend']['sendInvoice'] != ''){ ?>
     171            <tr>
     172            <th scope="row">
     173              <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
     174            </th>
     175            <td>
     176              <select id="<?php echo $id ?>" name="<?php echo $name ?>">
     177              <?php if(!empty($_SESSION[$id])){ ?>
     178                <option value="0">Select one...</option>
     179              <?php }
     180              echo $_SESSION[$id]; ?>
    166181            </td>
    167182          </tr>
  • drivefx-woocommerce/trunk/settings/syncro_gate.php

    r2558913 r2560157  
    11<?php
    2 require_once  __DIR__.'/../includes/class-wc-order-item-tax.php';
    32require_once  __DIR__.'/../PHCLibrary/log.php';
    43require_once  __DIR__.'/../PHCLibrary/utils.php';
     
    224223                    $syncroData->sendInvoice = $settings['backend']['sendInvoice'];
    225224                }
     225                if(isset($settings['backend']['typeOfReport'])) {
     226                    $syncroData->typeOfReport = $settings['backend']['typeOfReport'];
     227                }
    226228
    227229
     
    884886            $settings->warehouse = $wooOrder->warehouse;
    885887            $settings->sendInvoice = $wooOrder->sendInvoice;
     888            $settings->typeOfReport = $wooOrder->typeOfReport;
    886889
    887890            #shop data
Note: See TracChangeset for help on using the changeset viewer.