Exemplo n.º 1
0
 protected function lstFromCompany_Select()
 {
     // Clear any displayed warnings
     $this->lblNewFromContact->Warning = '';
     if ($this->lstFromCompany->SelectedValue) {
         $objCompany = Company::Load($this->lstFromCompany->SelectedValue);
         if ($objCompany) {
             // Load the values for the 'From Contact' List
             if ($this->lstFromContact) {
                 $objFromContactArray = Contact::LoadArrayByCompanyId($objCompany->CompanyId);
                 if ($this->lstFromContact->SelectedValue) {
                     $SelectedContactId = $this->lstFromContact->SelectedValue;
                 } elseif ($this->objReceipt->FromContactId) {
                     $SelectedContactId = $this->objReceipt->FromContactId;
                 } else {
                     $SelectedContactId = null;
                 }
                 $this->lstFromContact->RemoveAllItems();
                 $this->lstFromContact->AddItem('- Select One -', null);
                 if ($objFromContactArray) {
                     foreach ($objFromContactArray as $objFromContact) {
                         $objListItem = new QListItem($objFromContact->__toString(), $objFromContact->ContactId);
                         if ($SelectedContactId == $objFromContact->ContactId) {
                             $objListItem->Selected = true;
                         }
                         $this->lstFromContact->AddItem($objListItem);
                     }
                 }
                 $this->lstFromContact->Enabled = true;
             }
         }
     }
 }
Exemplo n.º 2
0
 protected function Form_PreRender()
 {
     $this->dtgContact->TotalItemCount = Contact::CountByCompanyId($this->objCompany->CompanyId);
     if ($this->dtgContact->TotalItemCount == 0) {
         $this->dtgContact->ShowHeader = false;
     } else {
         $objClauses = array();
         if ($objClause = $this->dtgContact->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgContact->LimitClause) {
             array_push($objClauses, $objClause);
         }
         $this->dtgContact->DataSource = Contact::LoadArrayByCompanyId($this->objCompany->CompanyId, $objClauses);
         $this->dtgContact->ShowHeader = true;
     }
     $this->dtgAddress->TotalItemCount = Address::CountByCompanyId($this->objCompany->CompanyId);
     if ($this->dtgAddress->TotalItemCount == 0) {
         $this->dtgAddress->ShowHeader = false;
     } else {
         $objClauses = array();
         if ($objClause = $this->dtgAddress->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgAddress->LimitClause) {
             array_push($objClauses, $objClause);
         }
         $this->dtgAddress->DataSource = Address::LoadArrayByCompanyId($this->objCompany->CompanyId, $objClauses);
         $this->dtgAddress->ShowHeader = true;
     }
     // Do not show the datagrids or 'Create New' buttons if creating a new company
     if (!$this->blnEditMode) {
         $this->btnCreateContact->Visible = false;
         $this->dtgContact->Visible = false;
         $this->btnCreateAddress->Visible = false;
         $this->dtgAddress->Visible = false;
     }
 }
Exemplo n.º 3
0
 public function lstToCompany_Select()
 {
     if ($this->pnlShipmentMassEdit->lstToCompany->SelectedValue) {
         $objCompany = Company::Load($this->pnlShipmentMassEdit->lstToCompany->SelectedValue);
         if ($objCompany) {
             // Load the values for the 'To Contact' List
             if ($this->pnlShipmentMassEdit->lstToContact) {
                 $objToContactArray = Contact::LoadArrayByCompanyId($objCompany->CompanyId, QQ::Clause(QQ::OrderBy(QQN::Contact()->LastName, QQN::Contact()->FirstName)));
                 $this->pnlShipmentMassEdit->lstToContact->RemoveAllItems();
                 if ($objToContactArray) {
                     foreach ($objToContactArray as $objToContact) {
                         $objListItem = new QListItem($objToContact->__toString(), $objToContact->ContactId);
                         $this->pnlShipmentMassEdit->lstToContact->AddItem($objListItem);
                     }
                     $this->pnlShipmentMassEdit->lstToContact->Enabled = true;
                 }
             }
             // Load the values for the 'To Address' List
             if ($this->pnlShipmentMassEdit->lstToAddress) {
                 $objToAddressArray = Address::LoadArrayByCompanyId($objCompany->CompanyId, QQ::Clause(QQ::OrderBy(QQN::Address()->ShortDescription)));
                 $this->pnlShipmentMassEdit->lstToAddress->RemoveAllItems();
                 if ($objToAddressArray) {
                     foreach ($objToAddressArray as $objToAddress) {
                         $objListItem = new QListItem($objToAddress->__toString(), $objToAddress->AddressId);
                         $this->pnlShipmentMassEdit->lstToAddress->AddItem($objListItem);
                     }
                     $this->pnlShipmentMassEdit->lstToAddress->Enabled = true;
                     //$this->lstToAddress_Select();
                 }
             }
         }
     }
 }
 public function lstToCompany_Select()
 {
     if ($this->lstToCompany->SelectedValue) {
         $objCompany = Company::Load($this->lstToCompany->SelectedValue);
         if ($objCompany) {
             // Load the values for the 'To Contact' List
             if ($this->lstToContact) {
                 $objToContactArray = Contact::LoadArrayByCompanyId($objCompany->CompanyId, QQ::Clause(QQ::OrderBy(QQN::Contact()->LastName, QQN::Contact()->FirstName)));
                 $this->lstToContact->RemoveAllItems();
                 $this->lstToContact->AddItem('- Select One -', null);
                 if ($objToContactArray) {
                     foreach ($objToContactArray as $objToContact) {
                         $objListItem = new QListItem($objToContact->__toString(), $objToContact->ContactId);
                         $this->lstToContact->AddItem($objListItem);
                     }
                     $this->lstToContact->Enabled = true;
                 }
             }
         }
     } else {
         $this->lstToContact->Enabled = false;
         $this->lstToContact->RemoveAllItems();
         $this->lstToContact->AddItem('- Select One -', null);
     }
 }
Exemplo n.º 5
0
 protected function lstToCompany_Select()
 {
     $this->disableAdvancedIfInternal();
     // Clear any displayed warnings
     if ($this->lblNewToContact) {
         $this->lblNewToContact->Warning = '';
         $this->lblNewToAddress->Warning = '';
     }
     if ($this->lstToCompany->SelectedValue) {
         $objCompany = Company::Load($this->lstToCompany->SelectedValue);
         if ($objCompany) {
             // Load the values for the 'To Contact' List
             if ($this->lstToContact) {
                 $objToContactArray = Contact::LoadArrayByCompanyId($objCompany->CompanyId, QQ::Clause(QQ::OrderBy(QQN::Contact()->LastName, QQN::Contact()->FirstName)));
                 if ($this->lstToContact->SelectedValue) {
                     $SelectedContactId = $this->lstToContact->SelectedValue;
                 } elseif ($this->objShipment->ToContactId) {
                     $SelectedContactId = $this->objShipment->ToContactId;
                 } else {
                     $SelectedContactId = null;
                 }
                 $this->lstToContact->RemoveAllItems();
                 $this->lstToContact->AddItem('- Select One -', null);
                 if ($objToContactArray) {
                     foreach ($objToContactArray as $objToContact) {
                         $objListItem = new QListItem($objToContact->__toString(), $objToContact->ContactId);
                         if ($SelectedContactId == $objToContact->ContactId) {
                             $objListItem->Selected = true;
                         }
                         $this->lstToContact->AddItem($objListItem);
                     }
                     $this->lstToContact->Enabled = true;
                 }
             }
             // Load the values for the 'To Address' List
             if ($this->lstToAddress) {
                 $objToAddressArray = Address::LoadArrayByCompanyId($objCompany->CompanyId, QQ::Clause(QQ::OrderBy(QQN::Address()->ShortDescription)));
                 if ($this->lstToAddress->SelectedValue) {
                     $SelectedAddressId = $this->lstToAddress->SelectedValue;
                 } elseif ($this->objShipment->ToAddressId) {
                     $SelectedAddressId = $this->objShipment->ToAddressId;
                 } else {
                     $SelectedAddressId = null;
                 }
                 $this->lstToAddress->RemoveAllItems();
                 $this->lstToAddress->AddItem('- Select One -', null);
                 if ($objToAddressArray) {
                     foreach ($objToAddressArray as $objToAddress) {
                         $objListItem = new QListItem($objToAddress->__toString(), $objToAddress->AddressId);
                         if ($SelectedAddressId == $objToAddress->AddressId) {
                             $objListItem->Selected = true;
                         }
                         $this->lstToAddress->AddItem($objListItem);
                     }
                     $this->lstToAddress->Enabled = true;
                     $this->lstToAddress_Select();
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
    /**
     * Deletes all associated Contacts
     * @return void
     */
    public function DeleteAllContacts()
    {
        if (is_null($this->intCompanyId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateContact on this unsaved Company.');
        }
        // Get the Database Object for this Class
        $objDatabase = Company::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (Contact::LoadArrayByCompanyId($this->intCompanyId) as $objContact) {
                $objContact->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`contact`
				WHERE
					`company_id` = ' . $objDatabase->SqlVariable($this->intCompanyId) . '
			');
    }
Exemplo n.º 7
0
 /**
  * Gets all associated Contacts as an array of Contact objects
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return Contact[]
  */
 public function GetContactArray($objOptionalClauses = null)
 {
     if (is_null($this->intCompanyId)) {
         return array();
     }
     try {
         return Contact::LoadArrayByCompanyId($this->intCompanyId, $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
 public function lstToCompany_Select()
 {
     if ($this->lstToCompany->SelectedValue) {
         $objCompany = Company::Load($this->lstToCompany->SelectedValue);
         if ($objCompany) {
             // Load the values for the 'To Contact' List
             if ($this->lstToContact) {
                 $objToContactArray = Contact::LoadArrayByCompanyId($objCompany->CompanyId, QQ::Clause(QQ::OrderBy(QQN::Contact()->LastName, QQN::Contact()->FirstName)));
                 $this->lstToContact->RemoveAllItems();
                 $this->lstToContact->AddItem('Any', 'any_' . $objCompany->CompanyId);
                 if ($objToContactArray) {
                     foreach ($objToContactArray as $objToContact) {
                         $objListItem = new QListItem($objToContact->__toString(), $objToContact->ContactId);
                         $this->lstToContact->AddItem($objListItem);
                     }
                     //$this->lstToContact->Enabled = true;
                 }
                 // For companies that have no contacts
                 // Removed because SQL-query causes no errors
                 /*else {
                 		  $this->lstToContact->RemoveAllItems();
                 		  $this->lstToContact->AddItem('- Select One -', null);
                 		}*/
             }
         }
     } else {
         //$this->lstToContact->Enabled = false;
         $this->lstToContact->RemoveAllItems();
         $this->lstToContact->AddItem('- Select One -', null);
         $this->lstToContact->AddItem('Any', 'any');
     }
 }