Changeset 2711081
- Timestamp:
- 04/18/2022 02:03:24 PM (4 years ago)
- Location:
- drivefx-woocommerce/trunk
- Files:
-
- 7 edited
-
PHCLibrary/invoices.php (modified) (8 diffs)
-
PHCLibrary/orders.php (modified) (10 diffs)
-
PHCLibrary/utils.php (modified) (1 diff)
-
class.DriveFxWoocommerce.php (modified) (20 diffs)
-
drivefx-woocommerce.php (modified) (1 diff)
-
settings/backend.php (modified) (2 diffs)
-
settings/syncro_gate.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
drivefx-woocommerce/trunk/PHCLibrary/invoices.php
r2633497 r2711081 163 163 #actEntity 164 164 $response = $this->utils_services->actEntity($ch, $credentials, 'FtWS', $response); 165 166 165 //$this->logs->writeFileLog('actEntity:', $response); 167 166 … … 184 183 185 184 $fi->ref = $product['ref']; 186 $fi->design = $product['design'];185 //$fi->design = $product['design']; 187 186 $fi->qtt= $product['qtt']; 188 187 $fi->etiliquido = $product['etiliquido']; … … 442 441 $this->logs->writeFileLog('addSimpleFT13', $response['messages'][0]['messageCodeLocale']); 443 442 } else { 443 444 //Insert designation for products 445 foreach ($response['result'][0]['fis'] as &$fis) { 446 foreach ($cart as $product) { 447 if ($fis['ref'] == $product['ref'] && $fis['design'] == "") { 448 //if ($fis['ref'] == $product['ref'] && $fis['design'] != $product['design']) { 449 //fill the designation 450 $fis['design'] = $product['design']; 451 } 452 } 453 } 444 454 //Save Invoice 445 455 $response = $this->utils_services->paramsSave($ch, $credentials, 'FtWS', $response); 446 447 456 //$this->logs->writeFileLog('saveFt:', $response); 448 457 … … 500 509 # get the invoice serie to use 501 510 $invoiceSerie = $this->getInvoiceSerieToUse($ch, $credentials, $dataPack); 502 503 511 //$this->logs->writeFileLog('invoiceSerie response:', $invoiceSerie); 504 512 … … 509 517 //Obtain new instance of FT based in Bo(bostamp) 510 518 $response = $this->utils_services->paramsNewInstanceFromReference($ch, $credentials, $response['bostamp'], $invoiceSerie); 511 512 519 //$this->logs->writeFileLog('instanceFromReference:', $response); 513 520 … … 530 537 #actEntity 531 538 $response = $this->utils_services->actEntity($ch, $credentials, 'FtWS', $response); 532 533 539 //$this->logs->writeFileLog('actEntity:', $response); 534 540 535 541 //Save Invoice 536 542 $response = $this->utils_services->paramsSave($ch, $credentials, 'FtWS', $response); 537 538 543 //$this->logs->writeFileLog('paramsSave:', $response); 539 544 … … 553 558 554 559 $response = $this->utils_services->paramsSignDocument($ch, $credentials, $ftstamp); 555 556 560 //$this->logs->writeFileLog('signing ft: ', $response); 557 561 } … … 564 568 $this->logs->writeFileLog('addInternalDocumentInvoice4', $response['messages'][0]['messageCodeLocale']); 565 569 } else { 566 $this->logs->writeFileLog(' addInternalDocumentInvoice4', "Invoice number: ".$response['result'][0]['fno']." was created!" );570 $this->logs->writeFileLog('Notice:', "Invoice nº: ".$response['result'][0]['fno']." was successfully created." ); 567 571 568 572 return $response; -
drivefx-woocommerce/trunk/PHCLibrary/orders.php
r2688315 r2711081 146 146 147 147 $response = $this->utils_services->filterItem_Query($ch, $credentials, 'Bo', $filterItem, $valueItem); 148 149 //$this->logs->writeFileLog('Responses', $response); 148 // $this->logs->writeFileLog('Responses', $response); 150 149 151 150 if (curl_error($ch)) { … … 240 239 //Check the customer by number 241 240 $response2 = $this->utils_services->filterItem_Query($ch, $credentials, 'Cl', 'no', $newCustomer->no); 242 243 241 // $this->logs->writeFileLog('custom_by_no:', $response2); 244 242 … … 256 254 #Save internal document 257 255 $response = $this->utils_services->paramsSave($ch, $credentials, 'BoWS', $response); 258 259 //$this->logs->writeFileLog('save2:', $response); 256 $this->logs->writeFileLog('save update order:', $response); 260 257 261 258 if (curl_error($ch)) { … … 288 285 289 286 $response = $this->utils_services->filterItem_Query($ch, $credentials, 'Bo', 'obrano', $_REQUEST['order_id']); 290 291 287 //$this->logs->writeFileLog('Response', $response); 292 288 … … 358 354 //Obtain new instance of Bo 359 355 $response = $this->utils_services->paramsNewInstance($ch, $credentials, 'BoWS', $settings->typeOfOrder); 360 361 356 //$this->logs->writeFileLog('BoWs NewInstance', $response); 362 357 … … 419 414 $this->logs->writeFileLog('addNewOrder13.1.1', $responseTaxes['messages'][0]['messageCodeLocale']); 420 415 } 421 416 422 417 #Obtain VO with updated Bo 423 418 foreach ($order->cart as $product) { … … 426 421 $bi = new stdClass(); 427 422 428 $bi->ref = $product['ref']; 429 $bi->design = $product['design']; 423 $bi->ref = $product['ref']; 430 424 $bi->armazem = $settings->warehouseOrder; 431 425 //fulfill Bis 432 426 $response['result'][0]['bis'][] = $bi; 433 434 //$this->logs->writeFileLog('bis build:', $response['result'][0]['bis']); 435 } 436 } 427 } 428 } 429 //$this->logs->writeFileLog('bis build:', $response['result'][0]['bis']); 437 430 438 431 #shipping … … 490 483 //actEntity 491 484 $response2 = $this->utils_services->actEntity($ch, $credentials, 'BoWS', $response); 492 493 //$this->logs->writeFileLog('response2:', $response2['result']); 485 //$this->logs->writeFileLog('response2:', $response2['result'][0]['bis']); 494 486 495 487 // Update shipping value … … 505 497 //actEntity 506 498 $response = $this->utils_services->actEntity($ch, $credentials, 'BoWS', $response2); 507 508 499 //$this->logs->writeFileLog('actEntity1:', $response['result']); 509 500 … … 753 744 } 754 745 else { 755 756 746 $response['result'][0]['obrano'] = $order->nextPostId; 747 } 748 749 //Insert designation for products 750 foreach ($response['result'][0]['bis'] as &$bis) { 751 foreach ($order->cart as $product) { 752 if ($bis['ref'] == $product['ref'] && $bis['design'] == "") { 753 //if ($bis['ref'] == $product['ref'] && $bis['design'] != $product['design']) { 754 //fill the designation 755 $bis['design'] = $product['design']; 756 } 757 } 757 758 } 758 759 759 760 #Save internal document 760 761 $response = $this->utils_services->paramsSave($ch, $credentials, 'BoWS', $response); 761 762 762 //$this->logs->writeFileLog('save1:', $response); 763 763 -
drivefx-woocommerce/trunk/PHCLibrary/utils.php
r2633497 r2711081 254 254 }' 255 255 ); 256 //Build Http query using params 257 $this->query = http_build_query ($this->params); 258 259 //Called webservice that make a request 260 $response=$this->doPhcRequest($ch, $this->url, $this->params, $credentials); 261 262 return $response; 263 } 264 265 /******************************************************************* 266 * --- Query with Warehouse & Included Price --- * 267 ********************************************************************/ 268 /** Header to create Query of webservice called **/ 269 public function warehouseInclPriceQuery($ch, $credentials, $entityName, $armazem, $comparison = null, $filterItem = null, $valueItem = null, $comparisonTwo = null, $filterItemTwo = null, $valueItemTwo = null){ 270 $this->url = $credentials->backendUrl."/REST/SearchWS/QueryAsEntities"; 271 //Create map with request parameters 272 $this->params = array ('itemQuery' => '{"distinct": true, 273 "groupByItems": [], 274 "lazyLoaded": false, 275 "offset": 0, 276 "orderByItems":[], 277 "SelectItems": [ 278 "st.ref", 279 "st.design", 280 "st.familia", 281 "st.stock" 282 ], 283 "entityName": "'.$entityName.'", 284 "filterItems": [{ 285 "comparison":"'.$comparison.'", 286 "filterItem":"'.$filterItem.'", 287 "valueItem":"'.$valueItem.'", 288 "groupItem":1, 289 "checkNull":false, 290 "skipCheckType":false, 291 "type":"Number" 292 }, 293 { 294 "comparison":"'.$comparisonTwo.'", 295 "filterItem":"'.$filterItemTwo.'", 296 "valueItem":"'.$valueItemTwo.'", 297 "groupItem":1, 298 "checkNull":false, 299 "skipCheckType":false, 300 "type":"Number" 301 }], 302 "joinEntities": [{ 303 "tableName": "sa", 304 "joinType": 1, 305 "joinExp": [{ 306 "filterItem": "sa.ref", 307 "comparison": 0, 308 "valueItem": "<#var>st.ref", 309 "groupItem": 1 310 }, 311 { 312 "filterItem": "sa.armazem", 313 "comparison": 0, 314 "valueItem": "'.$armazem.'", 315 "groupItem": 0 316 }] 317 }] 318 }' 319 ); 320 321 // Build Http query using params 322 $this->query = http_build_query ($this->params); 323 324 //Called webservice that make a request 325 $response=$this->doPhcRequest($ch, $this->url, $this->params, $credentials); 326 return $response; 327 } 328 329 /******************************************************************* 330 * --- FilterItem comparison --- * 331 ********************************************************************/ 332 /** Query with a comparison filter **/ 333 334 public function warehouseNoPriceQuery($ch, $credentials, $entityName, $armazem, $comparison, $filterItem = null, $valueItem = null){ 335 $this->url = $credentials->backendUrl."/REST/SearchWS/QueryAsEntities"; 336 //Create map with request parameters 337 $this->params = array ('itemQuery' => '{"distinct": true, 338 "groupByItems": [], 339 "lazyLoaded": false, 340 "offset": 0, 341 "orderByItems":[], 342 "SelectItems": [ 343 "st.ref", 344 "st.design", 345 "st.familia", 346 "st.stock" 347 ], 348 "entityName": "'.$entityName.'", 349 "filterItems": [{ 350 "comparison":"'.$comparison.'", 351 "filterItem":"'.$filterItem.'", 352 "valueItem":"'.$valueItem.'", 353 "groupItem":1, 354 "checkNull":false, 355 "skipCheckType":false, 356 "type":"Number" 357 }], 358 "joinEntities": [{ 359 "tableName": "sa", 360 "joinType": 1, 361 "joinExp": [{ 362 "filterItem": "sa.ref", 363 "comparison": 0, 364 "valueItem": "<#var>st.ref", 365 "groupItem": 1 366 }, 367 { 368 "filterItem": "sa.armazem", 369 "comparison": 0, 370 "valueItem": "'.$armazem.'", 371 "groupItem": 0 372 }] 373 }] 374 }' 375 ); 376 256 377 //Build Http query using params 257 378 $this->query = http_build_query ($this->params); -
drivefx-woocommerce/trunk/class.DriveFxWoocommerce.php
r2633497 r2711081 1124 1124 $credentials->token = $response['result'][0]['token']; 1125 1125 1126 //$this->logs->writeFileLog('completedOrder Login:', $response);1127 1128 1126 if (curl_error($ch)) { 1129 1127 $this->logs->writeFileLog('updateTypeOfOrders', $ch); … … 1222 1220 $credentials->token = $response['result'][0]['token']; 1223 1221 1224 //$this->logs->writeFileLog('completedOrder Login:', $response);1225 1226 1222 if (curl_error($ch)) { 1227 1223 $this->logs->writeFileLog('statusOfOrder', $ch); … … 1231 1227 $this->logs->writeFileLog('statusOfOrder', $response['messages'][0]['messageCodeLocale']); 1232 1228 } else { 1229 1233 1230 //Obtain type invoices 1234 1231 $response = $this->utils_services->paramsQuery4($ch, $credentials, 'Ts', $selectItems, $typeOfOrder); 1235 1236 1232 //$this->logs->writeFileLog('Type Invoices:', $response); 1237 1233 … … 1276 1272 public function cancelOrder($order_id){ 1277 1273 $this->lockStart(); 1274 $this->logs->writeFileLog('cancelOrder', "Enter for ID: ".$order_id); 1275 1278 1276 $settings = get_option(DRIVEFXWOOCOMMERCE_PLUGIN_NAME); 1279 1280 1277 // get Credentials 1281 1278 $credentials = $this->syncro_services->fetchCredentials(); … … 1286 1283 // send response as JSON 1287 1284 $response = json_decode($response, true); 1288 // get the temporary token and insert in credentials object1289 $credentials->token = $response['result'][0]['token'];1290 1291 1285 //$this->logs->writeFileLog('cancelOrder Login:', $response); 1292 1286 1293 1287 if (curl_error($ch)) { 1294 $this->logs->writeFileLog(' addNewOrder', $ch);1288 $this->logs->writeFileLog('cancelOrder', $ch); 1295 1289 } else if(empty($response)){ 1296 $this->logs->writeFileLog(' addNewOrder', 'EMPTY RESPONSE');1290 $this->logs->writeFileLog('cancelOrder', 'EMPTY RESPONSE'); 1297 1291 } else if(isset($response['messages'][0]['messageCodeLocale'])){ 1298 $this->logs->writeFileLog(' addNewOrder', $response['messages'][0]['messageCodeLocale']);1292 $this->logs->writeFileLog('cancelOrder', $response['messages'][0]['messageCodeLocale']); 1299 1293 } else { 1300 //Obtain gama of PHC 1301 $response = $this->utils_services->paramsGetBackEndInfo($ch, $credentials); 1302 1303 //$this->logs->writeFileLog('cancelOrder BackEnd:', $response); 1294 // get the temporary token and insert in credentials object 1295 $credentials->token = $response['result'][0]['token']; 1296 1297 //Obtain gama of PHC 1298 $response = $this->utils_services->paramsGetBackEndInfo($ch, $credentials); 1299 //$this->logs->writeFileLog('cancelOrder BackEnd:', $response); 1304 1300 1305 1301 if (curl_error($ch)) { … … 1316 1312 //Obtain currency coin of company 1317 1313 $response = $this->utils_services->filterItem_Query($ch, $credentials, 'E1', 'estab', 0); 1318 1319 1314 //$this->logs->writeFileLog('E1 response:', $response); 1320 1321 1315 1322 1316 if (curl_error($ch)) { … … 1329 1323 //Verify if currency of shop corresponds to PHC 1330 1324 if($response['result'][0]['moeda'] == get_option('woocommerce_currency')){ 1325 1331 1326 $post_ID = sanitize_text_field( $order_id ); 1332 1327 //Obtain stamp of internal document based in order … … 1337 1332 //Verify if exists in bd 1338 1333 $response = $this->utils_services->filterItem_Query($ch, $credentials, 'Bo', $filterItem, $valueItem); 1339 1340 1334 //$this->logs->writeFileLog('Bo response:', $response); 1341 1335 … … 1347 1341 $this->logs->writeFileLog('cancelOrder3', $response['messages'][0]['messageCodeLocale']); 1348 1342 } else { 1349 1350 //If is not a SAFT document we update the document 1351 if(!empty($response) && $response['result'][0]['isconfiguredtosign'] == false || ($response['result'][0]['isconfiguredtosign'] == true && 1352 $response['result'][0]['draftRecord'] == 1)){ 1353 1343 if(!empty($response['result'][0])){ 1354 1344 //Obtain status 1355 $statusOrderShop = $this->utils_services->genericFieldsList($settings['backend']['statusOfOrder']); 1356 //write in VO the status 1357 if(!empty($statusOrderShop)){ 1358 $response['result'][0][$statusOrderShop] = $this->fieldStatus; 1359 } 1360 //Update operation 1361 $response['result'][0]['Operation'] = 2; 1362 1363 $response = $this->utils_services->paramsSave($ch, $credentials, 'BoWS', $response); 1364 1365 //$this->logs->writeFileLog('BoWs Save:', $response); 1366 1367 if (curl_error($ch)) { 1368 $this->logs->writeFileLog('cancelOrder4', $ch); 1369 } else if(empty($response)){ 1370 $this->logs->writeFileLog('cancelOrder4', 'EMPTY RESPONSE'); 1371 } else if(isset($response['messages'][0]['messageCodeLocale'])){ 1372 $this->logs->writeFileLog('cancelOrder4', $response['messages'][0]['messageCodeLocale']); 1373 } 1374 } 1345 $feldForStatus = $this->utils_services->genericFieldsList($settings['backend']['statusOfOrder']); 1346 //write in VO the status 1347 if(!empty($feldForStatus)){ 1348 1349 //Obtain order by ID 1350 $order = new WC_Order($order_id); 1351 //get status of order atualizated 1352 $response['result'][0][$feldForStatus] = $order->get_status(); 1353 1354 } 1355 //Update operation 1356 $response['result'][0]['Operation'] = 2; 1357 1358 //Save internal document 1359 $response = $this->utils_services->paramsSave($ch, $credentials, 'BoWS', $response); 1360 //$this->logs->writeFileLog('paramsSave1.1 bo', $response); 1361 1362 if (curl_error($ch)) { 1363 $this->logs->writeFileLog('cancelOrder4', $ch); 1364 } else if(empty($response)){ 1365 $this->logs->writeFileLog('cancelOrder4', 'EMPTY RESPONSE'); 1366 } else if(isset($response['messages'][0]['messageCodeLocale'])){ 1367 $this->logs->writeFileLog('cancelOrder4', $response['messages'][0]['messageCodeLocale']); 1368 } 1369 } 1375 1370 } 1376 1371 } … … 1381 1376 $this->auth_services->PHCLogout($ch, $credentials); 1382 1377 } 1378 $this->logs->writeFileLog('cancelOrder', "Exit for ID: ".$order_id); 1383 1379 $this->lockEnd(); 1384 1380 } … … 1387 1383 public function completedOrder($order_id){ 1388 1384 $this->lockStart(); 1389 $this->logs->writeFileLog('completedOrder', "Ent rei" . $order_id);1385 $this->logs->writeFileLog('completedOrder', "Enter " . $order_id); 1390 1386 $settings = get_option(DRIVEFXWOOCOMMERCE_PLUGIN_NAME); 1391 1387 1392 1388 // get Credentials 1393 $credentials = $this->syncro_services->fetchCredentials(); 1389 $credentials = $this->syncro_services->fetchCredentials(); 1394 1390 //Obtain configuration to make login 1395 1391 $ch = $this->auth_services->PHCLogin($ch, $credentials); … … 1402 1398 1403 1399 if (curl_error($ch)) { 1404 $this->logs->writeFileLog('completedOrder ', $ch);1400 $this->logs->writeFileLog('completedOrder1', $ch); 1405 1401 } else if(empty($response)){ 1406 $this->logs->writeFileLog('completedOrder ', 'EMPTY RESPONSE');1402 $this->logs->writeFileLog('completedOrder1', 'EMPTY RESPONSE'); 1407 1403 } else if(isset($response['messages'][0]['messageCodeLocale'])){ 1408 $this->logs->writeFileLog('completedOrder ', $response['messages'][0]['messageCodeLocale']);1404 $this->logs->writeFileLog('completedOrder1', $response['messages'][0]['messageCodeLocale']); 1409 1405 } else { 1410 1406 //Obtain information from company … … 1421 1417 if($response['result'][0]['moeda'] == get_option('woocommerce_currency')){ 1422 1418 1423 //If in settings of backoffice is checked option "create invoice"1419 ### Create Invoice (copy of dossier || new invoice) 1424 1420 if($settings['backend']['createInvoice'] == 'on'){ 1425 1421 //Obtain stamp of internal document based in order … … 1433 1429 //Obtain stamp of internal document based in order 1434 1430 if($order_received == ''){ 1435 $order_received = sanitize_text_field( $order_id);1431 $order_received = sanitize_text_field($order_id); 1436 1432 } 1437 1433 $docid = get_post_meta($order_received); … … 1443 1439 $valueItem = $docid['_docid'][sizeof($docid['_docid'])-1]; 1444 1440 } 1445 1446 //Obtain gama of PHC1447 $response = $this->utils_services->paramsGetBackEndInfo($ch, $credentials);1441 1442 //Obtain gama of PHC 1443 $response = $this->utils_services->paramsGetBackEndInfo($ch, $credentials); 1448 1444 1449 1445 if (curl_error($ch)) { … … 1458 1454 1459 1455 if($_SESSION['gamaDRIVEFX'] >= 9) { 1460 //Verify if exists in bd 1456 1457 //Verify if a internal dossier exists in bd 1461 1458 $response = $this->utils_services->filterItem_Query($ch, $credentials, 'Bo', $filterItem, $valueItem); 1462 1459 //$this->logs->writeFileLog('response bo', $response); 1460 1463 1461 if (curl_error($ch)) { 1464 1462 $this->logs->writeFileLog('completedOrder3', $ch); … … 1468 1466 $this->logs->writeFileLog('completedOrder3', $response['messages'][0]['messageCodeLocale']); 1469 1467 } else { 1470 1471 1472 if($response['result'][0]['isconfiguredtosign'] == false || ($response['result'][0]['isconfiguredtosign'] == true && 1473 $response['result'][0]['draftRecord'] == 1)){ 1474 1475 if(!empty($response['result'][0])){ 1476 //Obtain status 1477 $statusOrderShop = $this->utils_services->genericFieldsList($settings['backend']['statusOfOrder']); 1478 //write in VO the status 1479 if(!empty($statusOrderShop)){ 1480 $response['result'][0][$statusOrderShop] = $this->fieldStatus; 1481 } 1482 //Update operation 1483 $response['result'][0]['Operation'] = 2; 1484 1485 //Save internal document 1486 $response = $this->utils_services->paramsSave($ch, $credentials, 'BoWS', $response); 1487 1488 if (curl_error($ch)) { 1489 $this->logs->writeFileLog('completedOrder4', $ch); 1490 } else if(empty($response)){ 1491 $this->logs->writeFileLog('completedOrder4', 'EMPTY RESPONSE'); 1492 } else if(isset($response['messages'][0]['messageCodeLocale'])){ 1493 $this->logs->writeFileLog('completedOrder4', $response['messages'][0]['messageCodeLocale']); 1494 } 1468 //if($response['result'][0]['isconfiguredtosign'] == false || ($response['result'][0]['isconfiguredtosign'] == true && $response['result'][0]['draftRecord'] == 1)){ 1469 if(!empty($response['result'][0])){ 1470 //Obtain status 1471 $feldForStatus = $this->utils_services->genericFieldsList($settings['backend']['statusOfOrder']); 1472 //write in VO the status 1473 if(!empty($feldForStatus)){ 1474 1475 //Obtain order by ID 1476 $order = new WC_Order($order_id); 1477 //get status of order atualizated 1478 $response['result'][0][$feldForStatus] = $order->get_status(); 1479 1495 1480 } 1481 //Update operation 1482 $response['result'][0]['Operation'] = 2; 1483 1484 //Save internal document 1485 $response = $this->utils_services->paramsSave($ch, $credentials, 'BoWS', $response); 1486 //$this->logs->writeFileLog('paramsSave bo', $response); 1487 1488 if (curl_error($ch)) { 1489 $this->logs->writeFileLog('completedOrder4', $ch); 1490 } else if(empty($response)){ 1491 $this->logs->writeFileLog('completedOrder4', 'EMPTY RESPONSE'); 1492 } else if(isset($response['messages'][0]['messageCodeLocale'])){ 1493 $this->logs->writeFileLog('completedOrder4', $response['messages'][0]['messageCodeLocale']); 1494 } 1496 1495 } 1497 1496 //} 1498 1497 $response = $response['result'][0]; 1499 1498 1500 1499 if(!empty($response['bostamp'])){ 1501 1500 //Create Invoice only if is configurated type of invoices 1502 1501 if(isset($settings['backend']['typeOfInvoice']) && $settings['backend']['typeOfInvoice'] > 0){ 1503 1502 //Add FT from Bo 1504 $this->addInternalDocumentInvoice($response, $ch, $order_id, $credentials);1503 $this->addInternalDocumentInvoice($response, $ch, $order_id, $credentials); 1505 1504 } 1506 1505 } else { … … 1520 1519 $this->auth_services->PHCLogout($ch, $credentials); 1521 1520 //session_destroy(); 1522 $this->logs->writeFileLog('completedOrder', " Sair" . $order_id);1521 $this->logs->writeFileLog('completedOrder', "Exit" . $order_id); 1523 1522 $this->lockEnd(); 1524 1523 } 1525 1524 1526 1525 //Convert internal document to invoice 1527 public function addInternalDocumentInvoice($response, $ch, $order_id, $credentials){1528 1529 $this->logs->writeFileLog('addInternalDocumentInvoice', " Entrei addInternalDocumentInvoice ft:" .$order_id);1530 1531 $wooOrder = $this->syncro_services->fetchOrderData($order id);1532 $ftprodPack = $this->syncro_services->processFtProducts($order id);1526 public function addInternalDocumentInvoice($response, $ch, $order_id, $credentials){ 1527 1528 $this->logs->writeFileLog('addInternalDocumentInvoice', "Start copy of internal document, ID: ".$order_id); 1529 1530 $wooOrder = $this->syncro_services->fetchOrderData($order_id); 1531 $ftprodPack = $this->syncro_services->processFtProducts($order_id); 1533 1532 $dataPack = $this->syncro_services->transformWcToPhcData($wooOrder, $prodPack, $ftprodPack, $couponPack); 1534 1533 $response = $this->invoices_services->addInternalDocInvoice($response, $ch, $credentials, $dataPack); … … 1538 1537 $this->sendEmail($ch, $credentials, $response, $dataPack); 1539 1538 1540 $this->logs->writeFileLog('addInternalDocumentInvoice', " sai addInternalDocumentInvoice ft:" .$order_id);1539 $this->logs->writeFileLog('addInternalDocumentInvoice', "End copy of internal document, ID: ".$order_id); 1541 1540 } 1542 1541 … … 1859 1858 } 1860 1859 } else { 1861 //$response = $this->utils_services->entityName_Query($ch, $credentials, 'St'); 1862 $response = $this->utils_services->entityName_Query1($ch, $credentials, $settings['backend']['warehouse']); 1863 1864 //$this->logs->writeFileLog('response_with_armazem:', $response); 1860 1861 // Products with VAT included in price 1862 if(($woocommerce_calc_taxes == "no") || ($woocommerce_calc_taxes == "yes" && $settings['backend']['includeTaxonSendCost'] == "true")) { 1863 1864 if ($settings['backend']['positiveStock'] == 'on'){ 1865 $response = $this->utils_services->warehouseInclPriceQuery($ch, $credentials, 'St', $settings['backend']['warehouse'],'2', 'stock', '0', '0', $columnIva, '1'); 1866 } else { 1867 $response = $this->utils_services->warehouseNoPriceQuery($ch, $credentials, 'St', $settings['backend']['warehouse'], '0' , "st.".$columnIva, '1'); 1868 } 1869 1870 //$this->logs->writeFileLog('StList with tax:', $response); 1871 1872 } 1873 // Products without VAT included in price 1874 else if($woocommerce_calc_taxes == "yes" && $settings['backend']['includeTaxonSendCost'] == "false"){ 1875 1876 if ($settings['backend']['positiveStock'] == 'on'){ 1877 $response = $this->utils_services->warehouseInclPriceQuery($ch, $credentials, 'St', $settings['backend']['warehouse'], '2', 'stock', '0', '0', $columnIva, '0'); 1878 } else { 1879 $response = $this->utils_services->warehouseNoPriceQuery($ch, $credentials, 'St', $settings['backend']['warehouse'], '0' , $columnIva, '0'); 1880 } 1881 1882 //$this->logs->writeFileLog('StList without tax:', $response); 1883 1884 } 1885 1886 /* $response = $this->utils_services->entityName_Query1($ch, $credentials, $settings['backend']['warehouse']); 1887 $this->logs->writeFileLog('response_with_armazem:', $response); */ 1865 1888 1866 1889 } -
drivefx-woocommerce/trunk/drivefx-woocommerce.php
r2688315 r2711081 3 3 * Plugin Name: PHC GO WooCommerce 4 4 * Description: Easy integration between Woocommerce WordPress and your PHC GO installation. 5 * Version: 4.9. 05 * Version: 4.9.1 6 6 * Author: PHC Software, S.A. 7 7 * Author URI: https://www.phcgo.net/ -
drivefx-woocommerce/trunk/settings/backend.php
r2645234 r2711081 472 472 <?php $fieldsStatus = array('notSelected' => 'Select one...', 473 473 'nmdesc' => 'Main Description', 474 'texto1' => ' Name of Final Text',475 'texto2' => ' Name of Final Text 2',474 'texto1' => 'Delivery place (Classification)', 475 'texto2' => 'Observations (Classification)', 476 476 'texto3' => 'Name of Final Text 3', 477 477 'tmodelo' => 'Alphanumeric Field 1', … … 501 501 <?php $fieldsStatus = array('notSelected' => 'Select one...', 502 502 'nmdesc' => 'Main Description', 503 'texto1' => ' Name of Final Text',504 'texto2' => ' Name of Final Text 2',503 'texto1' => 'Delivery place (Classification)', 504 'texto2' => 'Observations (Classification)', 505 505 'texto3' => 'Name of Final Text 3', 506 506 'tmodelo' => 'Alphanumeric Field 1', -
drivefx-woocommerce/trunk/settings/syncro_gate.php
r2688315 r2711081 86 86 $syncroData = new stdClass(); 87 87 88 88 89 /******************************************************************* 89 90 * --- billing data --- * … … 262 263 263 264 //Obtain doc ID based in order 264 $docid = get_post_meta($ syncroData->post_ID);265 $docid = get_post_meta($order_id); 265 266 266 267 $syncroData->docId = $docid['_docid'][0]; … … 269 270 #Customer notes 270 271 $syncroData->obs = $_REQUEST['order_comments']; 271 272 272 #Get Currency from woocommerce 273 273 $syncroData->wooCurrency = get_option('woocommerce_currency'); 274 275 274 #get order received endpoint from woocommerce 276 275 $syncroData->order_received = get_option('woocommerce_checkout_order_received_endpoint'); 277 278 276 #get company country from woocommerce 279 277 $syncroData->companyCountry = WC()->countries->countries[WC()->countries->get_base_country()]; 280 278 281 279 #get order tax rate country 282 $getTaxName = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM ".$wpdb->prefix."woocommerce_order_itemmeta WHERE meta_key='label' ORDER BY order_item_id DESC " ) ); 283 $syncroData->taxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_name='".$getTaxName."' LIMIT 1" ) ); 280 //$getTaxName = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM ".$wpdb->prefix."woocommerce_order_itemmeta WHERE meta_key='label' ORDER BY order_item_id DESC " ) ); 281 //$syncroData->taxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_name='".$getTaxName."' LIMIT 1" ) ); 282 283 $order = new WC_Order($order_id); 284 285 #get order tax rate country 286 foreach($order->get_items('tax') as $item_id => $item ) { 287 $tax_rate_id = $item->get_rate_id(); // Tax rate ID 288 } 289 $syncroData->taxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$tax_rate_id."' LIMIT 1" ) ); 284 290 291 //get status of order atualizated 292 $syncroData->statusOrder = $order->get_status(); 293 285 294 /******************************************************************* 286 295 * --- Alternative select Data --- * … … 344 353 $table_name = $wpdb->prefix."woocommerce_order_items"; 345 354 $query = "SELECT * FROM %s WHERE order_id = %s and order_item_type = 'shipping'"; 346 $resultShipping = $wpdb->get_row(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $packDocId->nextPostId))); 347 348 if(empty($resultShipping)){ 349 $resultShipping = $wpdb->get_row(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $order_id))); 350 } 355 $resultShipping = $wpdb->get_row(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $order_id))); 351 356 352 357 //get tax value for shipping … … 391 396 if(isset($getShippingTax)) { 392 397 $syncroData->shipping_tax = $getShippingTax; 393 } else if (isset($syncroData->shipping_taxValue) ) {398 } else if (isset($syncroData->shipping_taxValue) && isset($resultDB->meta_value) && $resultDB->meta_value != 0) { 394 399 $syncroData->shipping_tax = $syncroData->shipping_taxValue / $resultDB->meta_value * 100; 395 400 } else { … … 841 846 $typeproduct = $getproducttype->get_type(); 842 847 843 /* if ($typeproduct == 'variation'){844 if ( $product_id ) $wc_prod = new WC_Product_Variation( $product_id );845 }846 else {847 if ( $product_id ) $wc_prod = new WC_Product( $product_id );848 }849 850 $product['design'] = $wc_prod->get_name(); */851 852 848 if ($typeproduct == 'variation'){ 853 849 if ( $product_id ) $wc_prod = new WC_Product_Variation( $product_id ); 854 850 855 851 //for variation type, if exists, set the product designation according to the description 856 if ($wc_prod uct->get_description()) $product['design'] = $wc_prod->get_description(); else $product['design'] = $wc_prod->get_name();852 if ($wc_prod->get_description()) $product['design'] = $wc_prod->get_description(); else $product['design'] = $wc_prod->get_name(); 857 853 } else { 858 854 if ( $product_id ) $wc_prod = new WC_Product( $product_id ); … … 864 860 global $wpdb; 865 861 // order tax rate country 866 $getTaxID = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM ".$wpdb->prefix."woocommerce_order_itemmeta WHERE meta_key='rate_id' ORDER BY order_item_id DESC LIMIT 1" ) ); 867 $getTaxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$getTaxID."' LIMIT 1" ) ); 868 862 // $getTaxID = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM ".$wpdb->prefix."woocommerce_order_itemmeta WHERE meta_key='rate_id' ORDER BY order_item_id DESC LIMIT 1" ) ); 863 //$getTaxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$getTaxID."' LIMIT 1" ) ); 864 865 #get order tax rate country 866 foreach($order->get_items('tax') as $item_id => $item ) { 867 $tax_rate_id = $item->get_rate_id(); // Tax rate ID 868 } 869 $getTaxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$tax_rate_id."' LIMIT 1" ) ); 870 869 871 //order Item ID 870 872 //$getOrderItemID = $wpdb->get_var( $wpdb->prepare("SELECT order_item_id FROM ".$wpdb->prefix."woocommerce_order_items WHERE order_item_name ='".$product['design']."' and order_item_type = 'line_item' and order_id = '".$orderid."' LIMIT 1" ) ); … … 1023 1025 # order 1024 1026 $order->post_Id = $wooOrder->post_ID; 1027 $order->status = $wooOrder->statusOrder; 1025 1028 $order->doc_Id = $wooOrder->docId; 1026 1029 $order->order_Id = $wooOrder->orderId;
Note: See TracChangeset
for help on using the changeset viewer.