Exemple #1
0
    /**
     * Load an array of Shipment objects
     * by To Company, To Contact, From Company, From Contact, Shipment Number, Asset Code, Inventory Code, Tracking Number, or Status
     * using the shipment_custom_field_helper table
     *
     * @param string $strToCompany
     * @param string $strToContact
     * @param string $strFromCompany
     * @param string $strFromContact
     * @param string $strShipmentNumber
     * @param string $strAssetCode
     * @param string $strInventoryModelCode
     * @param int $intStatus
     * @param string $strTrackingNumber
     * @param int $intCourierId
     * @param string $strNote
     * @param string $strDateModified
     * @param string $strDateModifiedFirst
     * @param string $strDateModifiedLast
     * @param string $strOrderBy
     * @param string $strLimit
     * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding
     * @return Shipment[]
     */
    public static function LoadArrayBySearchHelper($strToCompany = null, $strToContact = null, $strFromCompany = null, $strFromContact = null, $strShipmentNumber = null, $strAssetCode = null, $strInventoryModelCode = null, $intStatus = null, $strTrackingNumber = null, $intCourierId = null, $strNote = null, $strShipmentDate = null, $arrCustomFields = null, $strDateModified = null, $strDateModifiedFirst = null, $strDateModifiedLast = null, $blnAttachment = null, $strOrderBy = null, $strLimit = null, $objExpansionMap = null)
    {
        Shipment::ArrayQueryHelper($strOrderBy, $strLimit, $strLimitPrefix, $strLimitSuffix, $strExpandSelect, $strExpandFrom, $objExpansionMap, $objDatabase);
        // Setup QueryExpansion
        $objQueryExpansion = new QQueryExpansion();
        if ($objExpansionMap) {
            try {
                Shipment::ExpandQuery('shipment', null, $objExpansionMap, $objQueryExpansion);
            } catch (QCallerException $objExc) {
                $objExc->IncrementOffset();
                throw $objExc;
            }
        }
        $arrSearchSql = Shipment::GenerateSearchSql($strToCompany, $strToContact, $strFromCompany, $strFromContact, $strShipmentNumber, $strAssetCode, $strInventoryModelCode, $intStatus, $strTrackingNumber, $intCourierId, $strNote, $strShipmentDate, $arrCustomFields, $strDateModified, $strDateModifiedFirst, $strDateModifiedLast, $blnAttachment);
        $arrAttachmentSql = Attachment::GenerateSql(EntityQtype::Shipment);
        $arrCustomFieldSql = CustomField::GenerateHelperSql(EntityQtype::Shipment);
        $strQuery = sprintf('
				SELECT
					%s
					DISTINCT
					`shipment`.`shipment_id` AS `shipment_id`,
					`shipment`.`shipment_number` AS `shipment_number`,
					`shipment`.`to_contact_id` AS `to_contact_id`,
					`shipment`.`from_company_id` AS `from_company_id`,
					`shipment`.`from_contact_id` AS `from_contact_id`,
					`shipment`.`transaction_id` AS `transaction_id`,
					`shipment`.`ship_date` AS `ship_date`,
					`shipment`.`from_address_id` AS `from_address_id`,
					`shipment`.`to_company_id` AS `to_company_id`,
					`shipment`.`to_address_id` AS `to_address_id`,
					`shipment`.`courier_id` AS `courier_id`,
					`shipment`.`shipped_flag` AS `shipped_flag`,
					`shipment`.`tracking_number` AS `tracking_number`,
					`shipment`.`created_by` AS `created_by`,
					`shipment`.`creation_date` AS `creation_date`,
					`shipment`.`modified_by` AS `modified_by`,
					`shipment`.`modified_date` AS `modified_date`
					%s
					%s
					%s
				FROM
					`shipment` AS `shipment`
					%s
					%s
					%s
					%s
					%s
				WHERE
				1=1
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
				%s
			', $strLimitPrefix, $objQueryExpansion->GetSelectSql(",\n\t\t\t\t\t", ",\n\t\t\t\t\t"), $arrCustomFieldSql['strSelect'], $arrAttachmentSql['strSelect'], $objQueryExpansion->GetFromSql("", "\n\t\t\t\t\t"), $arrCustomFieldSql['strFrom'], $arrAttachmentSql['strFrom'], $arrSearchSql['strAssetCodeFromSql'], $arrSearchSql['strInventoryModelCodeFromSql'], $arrSearchSql['strToCompanySql'], $arrSearchSql['strToContactSql'], $arrSearchSql['strFromCompanySql'], $arrSearchSql['strFromContactSql'], $arrSearchSql['strShipmentNumberSql'], $arrSearchSql['strAssetCodeSql'], $arrSearchSql['strInventoryModelCodeSql'], $arrSearchSql['strStatusSql'], $arrSearchSql['strTrackingNumberSql'], $arrSearchSql['strCourierSql'], $arrSearchSql['strNoteSql'], $arrSearchSql['strShipmentDateSql'], $arrSearchSql['strCustomFieldsSql'], $arrSearchSql['strDateModifiedSql'], $arrSearchSql['strAttachmentSql'], $arrSearchSql['strAuthorizationSql'], $arrAttachmentSql['strGroupBy'], $strOrderBy, $strLimitSuffix);
        $objDbResult = $objDatabase->Query($strQuery);
        return Shipment::InstantiateDbResult($objDbResult);
    }
 /**
  * Gets the historical journal for an object from the log database.
  * Objects will have VirtualAttributes available to lookup login, date, and action information from the journal object.
  * @param integer intShipmentId
  * @return Shipment[]
  */
 public static function GetJournalForId($intShipmentId)
 {
     $objDatabase = Shipment::GetDatabase()->JournalingDatabase;
     $objResult = $objDatabase->Query('SELECT * FROM shipment WHERE shipment_id = ' . $objDatabase->SqlVariable($intShipmentId) . ' ORDER BY __sys_date');
     return Shipment::InstantiateDbResult($objResult);
 }
 /**
  * Static Qcodo Query method to query for an array of Shipment objects.
  * Uses BuildQueryStatment to perform most of the work.
  * @param QQCondition $objConditions any conditions on the query, itself
  * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  * @return Shipment[] the queried objects as an array
  */
 public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null)
 {
     // Get the Query Statement
     try {
         $strQuery = Shipment::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     // Perform the Query and Instantiate the Array Result
     $objDbResult = $objQueryBuilder->Database->Query($strQuery);
     return Shipment::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes);
 }
         $objArray = Manufacturer::InstantiateDbResult($objDbResult);
         break;
     case 6:
         $objArray = Category::InstantiateDbResult($objDbResult);
         break;
     case 7:
         $objArray = Company::InstantiateDbResult($objDbResult);
         break;
     case 8:
         $objArray = Contact::InstantiateDbResult($objDbResult);
         break;
     case 9:
         $objArray = Address::InstantiateDbResult($objDbResult);
         break;
     case 10:
         $objArray = Shipment::InstantiateDbResult($objDbResult);
         break;
     case 11:
         $objArray = Receipt::InstantiateDbResult($objDbResult);
         break;
 }
 if ($objArray) {
     foreach ($objArray as $obj) {
         $strInsertAssetSql = '';
         if ($objEntityQtypeCustomFieldArray) {
             foreach ($objEntityQtypeCustomFieldArray as $objEntityQtypeCustomField) {
                 $strInsertAssetSql .= ", '" . addslashes($obj->GetVirtualAttribute($objEntityQtypeCustomField->CustomFieldId)) . "'";
             }
         }
         $strQuery = sprintf('INSERT INTO %s (%s_id %s) VALUES (%s %s);', $strHelperTable, $strTableName, $arrCustomFieldSql['strInsertColumnHeader'], $obj->{$strObjectId}, $strInsertAssetSql);
         echo $strQuery . "<br />";