|
|
@@ -2,6 +2,8 @@
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
+use App\Enums\DocumentTypes;
|
|
|
+
|
|
|
$core = Core::getInstance();
|
|
|
|
|
|
$user = $core->getUser();
|
|
|
@@ -21,6 +23,59 @@ if($term) {
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
+ // References
|
|
|
+ if(preg_match("/^([LGASD])(\d+)$/i", $term, $matches)) {
|
|
|
+ $type = strtoupper($matches[1]);
|
|
|
+ $number = $matches[2];
|
|
|
+
|
|
|
+ $document_type = null;
|
|
|
+
|
|
|
+ switch($type) {
|
|
|
+ case "L":
|
|
|
+ break;
|
|
|
+ case "G":
|
|
|
+ $document_type = DocumentTypes::GOODS_IN;
|
|
|
+ break;
|
|
|
+ case "A":
|
|
|
+ $document_type = DocumentTypes::ADVANCE_REPLACEMENT_UNIT;
|
|
|
+ break;
|
|
|
+ case "S":
|
|
|
+ $document_type = DocumentTypes::SALES_ORDER;
|
|
|
+ break;
|
|
|
+ case "D":
|
|
|
+ $document_type = DocumentTypes::DELIVERY_NOTE;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($document_type === null) {
|
|
|
+ $sale = Sale::getByNumber($number);
|
|
|
+ if($sale) {
|
|
|
+ $results[] = [
|
|
|
+ "type" => __("Lead"),
|
|
|
+ "match_reason" => __("Lead reference match."),
|
|
|
+ "name" => $sale->getTitle(),
|
|
|
+ "url" => $sale->getUrl()
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $document = Document::queryOne([
|
|
|
+ "number" => $number,
|
|
|
+ "type" => $document_type,
|
|
|
+ "dts_deleted" => null
|
|
|
+ ]);
|
|
|
+ if($document) {
|
|
|
+ $results[] = [
|
|
|
+ "type" => $document->getDisplayType(),
|
|
|
+ "match_reason" => __("%s reference match.", $document->getDisplayType()),
|
|
|
+ "name" => $document->getTitle(),
|
|
|
+ "url" => $document->getUrl()
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// Search sale and document numbers
|
|
|
if(is_numeric($term)) {
|
|
|
$documents = Document::query([
|