Example #1
0
function vtws_addDefaultActorTypeEntity($actorName, $actorNameDetails, $withName = true)
{
    $actorHandler = array('file' => 'include/Webservices/VtigerActorOperation.php', 'class' => 'VtigerActorOperation');
    if ($withName == true) {
        vtws_addActorTypeWebserviceEntityWithName($actorName, $actorHandler['file'], $actorHandler['class'], $actorNameDetails);
    } else {
        vtws_addActorTypeWebserviceEntityWithoutName($actorName, $actorHandler['file'], $actorHandler['class'], $actorNameDetails);
    }
}
ExecuteQuery($sql);
$result = $adb->pquery('SELECT organizationname FROM vtiger_organizationdetails', array());
$noOfCompanies = $adb->num_rows($result);
if ($noOfCompanies > 0) {
    for ($i = 0; $i < $noOfCompanies; ++$i) {
        $id = $adb->getUniqueID('vtiger_organizationdetails');
        $organizationName = $adb->query_result($result, $i, 'organizationname');
        ExecuteQuery("UPDATE vtiger_organizationdetails SET organization_id={$id} WHERE organizationname='{$organizationName}'");
    }
} else {
    $id = $adb->getUniqueID('vtiger_organizationdetails');
}
$sql = 'UPDATE vtiger_organizationdetails_seq SET id = (SELECT max(organization_id) FROM vtiger_organizationdetails)';
ExecuteQuery($sql);
// Add Webservice support for Company Details type of entity.
vtws_addActorTypeWebserviceEntityWithName('CompanyDetails', 'include/Webservices/VtigerCompanyDetails.php', 'VtigerCompanyDetails', array('fieldNames' => 'organizationname', 'indexField' => 'groupid', 'tableName' => 'vtiger_organizationdetails'));
$sql = 'CREATE TABLE vtiger_ws_fieldinfo(id varchar(64) NOT NULL PRIMARY KEY,
										property_name VARCHAR(32),
										property_value VARCHAR(64)
										) ENGINE=Innodb DEFAULT CHARSET=utf8;';
ExecuteQuery($sql);
$id = $adb->getUniqueID('vtiger_ws_entity_fieldtype');
$sql = "INSERT INTO vtiger_ws_entity_fieldtype(fieldtypeid,table_name,field_name,fieldtype) VALUES ({$id},'vtiger_organizationdetails','logoname','file')";
ExecuteQuery($sql);
$id = $adb->getUniqueID('vtiger_ws_entity_fieldtype');
$sql = "INSERT INTO vtiger_ws_entity_fieldtype(fieldtypeid,table_name,field_name,fieldtype) VALUES ({$id},'vtiger_organizationdetails','phone','phone')";
ExecuteQuery($sql);
$id = $adb->getUniqueID('vtiger_ws_entity_fieldtype');
$sql = "INSERT INTO vtiger_ws_entity_fieldtype(fieldtypeid,table_name,field_name,fieldtype) VALUES ({$id},'vtiger_organizationdetails','fax','phone')";
ExecuteQuery($sql);
$id = $adb->getUniqueID('vtiger_ws_entity_fieldtype');
 function vtws_addEntityInfo()
 {
     require_once 'include/Webservices/Utils.php';
     $names = vtws_getModuleNameList();
     $moduleHandler = array('file' => 'include/Webservices/VtigerModuleOperation.php', 'class' => 'VtigerModuleOperation');
     foreach ($names as $tab) {
         if (in_array($tab, array('Rss', 'Webmails', 'Recyclebin'))) {
             continue;
         }
         $entityId = $this->db->getUniqueID("vtiger_ws_entity");
         $this->db->pquery('insert into vtiger_ws_entity(id,name,handler_path,handler_class,ismodule) values (?,?,?,?,?)', array($entityId, $tab, $moduleHandler['file'], $moduleHandler['class'], 1));
     }
     $entityId = $this->db->getUniqueID("vtiger_ws_entity");
     $this->db->pquery('insert into vtiger_ws_entity(id,name,handler_path,handler_class,ismodule) values (?,?,?,?,?)', array($entityId, 'Events', $moduleHandler['file'], $moduleHandler['class'], 1));
     $entityId = $this->db->getUniqueID("vtiger_ws_entity");
     $this->db->pquery('insert into vtiger_ws_entity(id,name,handler_path,handler_class,ismodule) values (?,?,?,?,?)', array($entityId, 'Users', $moduleHandler['file'], $moduleHandler['class'], 1));
     vtws_addDefaultActorTypeEntity('Groups', array('fieldNames' => 'groupname', 'indexField' => 'groupid', 'tableName' => 'vtiger_groups'));
     require_once "include/Webservices/WebServiceError.php";
     require_once 'include/Webservices/VtigerWebserviceObject.php';
     $webserviceObject = VtigerWebserviceObject::fromName($this->db, 'Groups');
     $this->db->pquery("insert into vtiger_ws_entity_tables(webservice_entity_id,table_name) values\n\t\t\t(?,?)", array($webserviceObject->getEntityId(), 'vtiger_groups'));
     vtws_addDefaultActorTypeEntity('Currency', array('fieldNames' => 'currency_name', 'indexField' => 'id', 'tableName' => 'vtiger_currency_info'));
     $webserviceObject = VtigerWebserviceObject::fromName($this->db, 'Currency');
     $this->db->pquery("insert into vtiger_ws_entity_tables(webservice_entity_id,table_name) values (?,?)", array($webserviceObject->getEntityId(), 'vtiger_currency_info'));
     vtws_addDefaultActorTypeEntity('DocumentFolders', array('fieldNames' => 'foldername', 'indexField' => 'folderid', 'tableName' => 'vtiger_attachmentsfolder'));
     $webserviceObject = VtigerWebserviceObject::fromName($this->db, 'DocumentFolders');
     $this->db->pquery("insert into vtiger_ws_entity_tables(webservice_entity_id,table_name) values (?,?)", array($webserviceObject->getEntityId(), 'vtiger_attachmentsfolder'));
     vtws_addActorTypeWebserviceEntityWithName('CompanyDetails', 'include/Webservices/VtigerCompanyDetails.php', 'VtigerCompanyDetails', array('fieldNames' => 'organizationname', 'indexField' => 'groupid', 'tableName' => 'vtiger_organizationdetails'));
     $webserviceObject = VtigerWebserviceObject::fromName($this->db, 'CompanyDetails');
     $this->db->pquery('INSERT INTO vtiger_ws_entity_tables(webservice_entity_id,table_name) VALUES (?,?)', array($webserviceObject->getEntityId(), 'vtiger_organizationdetails'));
 }
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_fieldtype(fieldtypeid,table_name, field_name,fieldtype) VALUES (?,?,?,?);", array($fieldTypeId, 'vtiger_inventoryproductrel', 'id', "reference"));
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_referencetype(fieldtypeid,type) VALUES (?,?)", array($fieldTypeId, 'Invoice'));
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_referencetype(fieldtypeid,type) VALUES (?,?)", array($fieldTypeId, 'SalesOrder'));
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_referencetype(fieldtypeid,type) VALUES (?,?)", array($fieldTypeId, 'PurchaseOrder'));
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_referencetype(fieldtypeid,type) VALUES (?,?)", array($fieldTypeId, 'Quotes'));
$fieldTypeId = $adb->getUniqueID("vtiger_ws_entity_fieldtype");
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_fieldtype(fieldtypeid,table_name,field_name,fieldtype) VALUES (?,?,?,?);", array($fieldTypeId, 'vtiger_inventoryproductrel', 'incrementondel', "autogenerated"));
$adb->getUniqueID("vtiger_inventoryproductrel");
Migration_Index_View::ExecuteQuery("UPDATE vtiger_inventoryproductrel_seq SET id=(select max(lineitem_id) from vtiger_inventoryproductrel);", array());
Migration_Index_View::ExecuteQuery("UPDATE vtiger_ws_entity SET handler_path='include/Webservices/LineItem/VtigerInventoryOperation.php',handler_class='VtigerInventoryOperation' where name in ('Invoice','Quotes','PurchaseOrder','SalesOrder');", array());
$purchaseOrderTabId = getTabid("PurchaseOrder");
$purchaseOrderAddressInformationBlockId = getBlockId($purchaseOrderTabId, "LBL_ADDRESS_INFORMATION");
$invoiceTabId = getTabid("Invoice");
$invoiceTabIdAddressInformationBlockId = getBlockId($invoiceTabId, "LBL_ADDRESS_INFORMATION");
Migration_Index_View::ExecuteQuery('UPDATE vtiger_field SET block=? where tabid=? and block=?;', array($invoiceTabIdAddressInformationBlockId, $invoiceTabId, $purchaseOrderAddressInformationBlockId));
vtws_addActorTypeWebserviceEntityWithName('Tax', 'include/Webservices/LineItem/VtigerTaxOperation.php', 'VtigerTaxOperation', array('fieldNames' => 'taxlabel', 'indexField' => 'taxid', 'tableName' => 'vtiger_inventorytaxinfo'), true);
$webserviceObject = VtigerWebserviceObject::fromName($adb, 'Tax');
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_tables(webservice_entity_id,table_name) VALUES (?,?)", array($webserviceObject->getEntityId(), 'vtiger_inventorytaxinfo'));
vtws_addActorTypeWebserviceEntityWithoutName('ProductTaxes', 'include/Webservices/LineItem/VtigerProductTaxesOperation.php', 'VtigerProductTaxesOperation', array());
$webserviceObject = VtigerWebserviceObject::fromName($adb, 'ProductTaxes');
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_tables(webservice_entity_id,table_name) VALUES (?,?)", array($webserviceObject->getEntityId(), 'vtiger_producttaxrel'));
$fieldTypeId = $adb->getUniqueID("vtiger_ws_entity_fieldtype");
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_fieldtype(fieldtypeid,table_name,field_name,fieldtype) VALUES (?,?,?,?);", array($fieldTypeId, 'vtiger_producttaxrel', 'productid', "reference"));
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_referencetype(fieldtypeid,type) VALUES (?,?)", array($fieldTypeId, 'Products'));
$fieldTypeId = $adb->getUniqueID("vtiger_ws_entity_fieldtype");
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_fieldtype(fieldtypeid,table_name,field_name,fieldtype) VALUES (?,?,?,?);", array($fieldTypeId, 'vtiger_producttaxrel', 'taxid', "reference"));
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_ws_entity_referencetype(fieldtypeid,type) VALUES (?,?)", array($fieldTypeId, 'Tax'));
//--
//Changed Columns Display in List view of Leads
$leadsFirstName = 'vtiger_leaddetails:firstname:firstname:Leads_First_Name:V';
$leadsLastName = 'vtiger_leaddetails:lastname:lastname:Leads_Last_Name:V';