/** * @param Object $obj * @param string|null $thumbnail * @return string */ public static function getViewPath($obj, $thumbnail = null) { switch ($obj) { case $obj instanceof \User\Model\User: if (!$obj->getCreatedDateTime()) { return '/media/users/default/' . $obj->getId() . '/'; } $datePath = DateBase::toFormat($obj->getCreatedDateTime(), 'Ymd'); return '/media/user/' . $datePath . '/' . $obj->getId() . '/' . $obj->getAvatar(); break; } return ''; }
public function get(Object $oObject, $aParams = array()) { if (isset($this->aParams['ToModuleAlias'])) { Core::import('Modules.' . $this->aParams['ToModuleAlias']); } $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']); $aContainer = $oMapper->getContainer(); $sTable = $aContainer['TableName']; $sClassName = $aContainer['Object']; $oQuery = new DbFetcher($sTable, 'a'); $oQuery->addJoinTable($this->aParams['TableName'], 'b', 'LEFT JOIN', 'a.id = b.' . $this->aParams['Field']); $oQuery->addSelectField('a.*'); // Условия выборки $oCriteria = new CriteriaGroup('AND'); $oCriteria->addElement(new CriteriaElement($this->aParams['Field2'], '=', (int) $oObject->getId())); $oQuery->addCriteria($oCriteria->renderWhere()); if (isset($this->aParams['Order'])) { foreach ($this->aParams['Order'] as $k => $dir) { $oQuery->addOrder($k, $dir); } } else { $oQuery->addOrder('Pos', 'ASC'); } $oResult = new ObjectsCollection($oQuery); $aResult = $oQuery->fetchAll(); foreach ($aResult as $itm) { $oResult->add(new $sClassName($this->convRealFieldToFields($itm, '', $aContainer))); } return $oResult; }
/** * Transforms an object to an id. * * @param Object|null $entity * @return string */ public function transform($entity) { if (null === $entity) { return ""; } return $entity->getId(); }
/** * Prépare une liste de paramètres pour une requête SQL UPDATE ou INSERT * @param Object $objetMetier * @return array : tableau ordonné de valeurs */ public function objetVersEnregistrement($objetMetier) { // construire un tableau des paramètres d'insertion ou de modification // l'ordre des valeurs est important : il correspond à celui des paramètres de la requête SQL $retour = array(':id' => $objetMetier->getId(), ':libelle' => $objetMetier->getLibelle()); return $retour; }
/** * Transforms an object to a string (id). * * @param Object|null $object * @return string */ public function transform($object) { if (null === $object) { return ""; } return $object->getId(); }
/** * Transforms an object to a string (number). * * @param Object|null $entity * @return string|null */ public function transform($entity) { if (!$entity) { return null; } return $entity->getId(); }
public function get(Object $oObject, $aParams = array()) { if (isset($this->aParams['ToModuleAlias'])) { Core::import('Modules.' . $this->aParams['ToModuleAlias']); } $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']); $nLimit = 0; $nOffset = 0; $aLocCriteria = array($this->aParams['Field'] => $oObject->getId()); $aLocOrder = array('Pos' => 'ASC'); if (count($aParams) > 0) { if (isset($aParams['Criteria'])) { foreach ($aParams['Criteria'] as $key => $val) { $aLocCriteria[$key] = $val; } } if (isset($aParams['Order'])) { $aLocOrder = $aParams['Order']; } if (isset($aParams['Limit'])) { $nLimit = intval($aParams['Limit']); } if (isset($aParams['Offset'])) { $nOffset = intval($aParams['Offset']); } } $aDefaultParams = isset($this->aParams['Params']) ? $this->aParams['Params'] : array(); return $oMapper->find(ArrayHelper::merge($aDefaultParams, array('Order' => $aLocOrder, 'Criteria' => $aLocCriteria, 'Limit' => $nLimit, 'Offset' => $nOffset))); }
public function get(Object $oObject, $aParams = array()) { if (isset($this->aParams['ToModuleAlias'])) { Core::import('Modules.' . $this->aParams['ToModuleAlias']); } $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']); $aParams['Criteria'][$this->aParams['Field']] = $oObject->getId(); return $oMapper->findFirst($aParams); }
/** * Prepara os dados para o cancelamento da nota * @param string $sParametroArquivo */ public function preparaDados($sParametroArquivo) { $this->oDadosXML = $this->validaXML($sParametroArquivo); /** * Verifica se existe inconsistencias */ if (count($this->aInconsistencias) == 0) { $sCnpj = (string) $this->oDadosXML->IdentificacaoNfse->Cnpj; $sNumero = (string) $this->oDadosXML->IdentificacaoNfse->Numero; $iInscricaoMunicipal = (string) $this->oDadosXML->IdentificacaoNfse->InscricaoMunicipal; $iNumero = (int) substr($sNumero, 4, 11); $aAtributosContriobuinte = array("cnpj_cpf" => $sCnpj, "im" => $iInscricaoMunicipal); $sAmbiente = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); if (DBSeller_Plugin_Auth::checkPermissionWebservice($sCnpj, "webservice/{$sAmbiente}/recepcionar-lote-rps")) { $aContribuinte = Administrativo_Model_UsuarioContribuinte::getByAttributes($aAtributosContriobuinte); foreach ($aContribuinte as $oContribuinte) { $this->oContribuinte = $oContribuinte; } /** * Verifica se existe contribuinte com o CNPJ e Inscrição Municipal informado */ if (empty($this->oContribuinte)) { $this->adicionarInconsistencia('E44'); $this->adicionarInconsistencia('E50'); } else { $iIdContribuinte = $this->oContribuinte->getId(); $aAtributosNota = array("id_contribuinte" => $iIdContribuinte, "nota" => $iNumero); /** * Retornar a entidade do array de notas */ $aNotas = Contribuinte_Model_Nota::getByAttributes($aAtributosNota); foreach ($aNotas as $oNota) { $this->oNota = $oNota; } /** * Verifica se existe nota */ if (empty($this->oNota)) { $this->adicionarInconsistencia('E78'); } else { $bNotaCancelada = $this->oNota->getCancelada(); /** * Verifica se a nota já está cancelada */ if ($bNotaCancelada) { $this->adicionarInconsistencia('E79'); } } } } else { $this->adicionarInconsistencia('E157'); $this->adicionarInconsistencia('Usuário sem permissão!'); } } }
/** * Get a specific ticket * @param Object $realm * @param Int $ticketId * @return Array */ public function getTicket($realm, $ticketId = false) { if ($ticketId && $realm) { //Connect to the realm $realm->getCharacters()->connect(); //Do the query $query = $realm->getCharacters()->getConnection()->query("SELECT " . allColumns("gm_tickets", $realm->getId()) . " FROM " . table("gm_tickets", $realm->getId()) . " WHERE " . column("gm_tickets", "ticketId", false, $realm->getId()) . " = ?", array($ticketId)); if ($realm->getCharacters()->getConnection()->_error_message()) { die($realm->getCharacters()->getConnection()->_error_message()); } if ($query->num_rows() > 0) { $result = $query->result_array(); return $result[0]; } else { return false; } } else { return false; } }
/** * Returns file model. * @return null|Object|File */ public function getFile() { if (!$this->objectId) { return null; } if (isset($this->file) && $this->objectId == $this->file->getId()) { return $this->file; } //todo Here we can load anything (Folder or File). But now - only File model $this->file = File::loadById($this->objectId); return $this->file; }
/** * (non-PHPdoc) * @see \comhon\object\object\SerializationUnit::_loadObject() */ protected function _loadObject(Object $pObject) { $lId = $pObject->getId(); $lPath = $this->getValue("saticPath") . DIRECTORY_SEPARATOR . $lId . DIRECTORY_SEPARATOR . $this->getValue("staticName"); if (!file_exists($lPath)) { throw new \Exception("cannot load json file, file doesn't exists (id : {$lId})"); } $lStdClassObject = json_decode(file_get_contents($lPath)); if ($lStdClassObject !== false) { $pObject->fromObject($lStdClassObject); return true; } else { return false; } }
/** * (non-PHPdoc) * @see \comhon\object\object\SerializationUnit::_loadObject() */ protected function _loadObject(Object $pObject) { $lId = $pObject->getId(); $lPath = $this->getValue("saticPath") . DIRECTORY_SEPARATOR . $lId . DIRECTORY_SEPARATOR . $this->getValue("staticName"); if (!file_exists($lPath)) { throw new \Exception("cannot load xml file, file doesn't exists (id : {$lId})"); } $lSimpleXmlElement = simplexml_load_file($lPath); if ($lSimpleXmlElement !== false && !is_null($lSimpleXmlElement)) { $pObject->fromXml($lSimpleXmlElement); return true; } else { return false; } }
/** * Generate the record node for * the data node * @param DOMDocument $doc * @param DOMNode $parentNode * @param Object $record */ public function generateXml($doc, $parentNode, $record) { $tagRecord = $doc->createElement('record'); $tagRecord->setAttribute('id', $record->getId()); $previous = array(); foreach ($this->fields as $field) { if (!in_array($field->completeName(), $previous)) { $tag = $doc->createElement($field->completeName()); $text = $doc->createTextNode($field->getValue($record)); $tag->appendChild($text); $tagRecord->appendChild($tag); } $previous[count($previous)] = $field->getName(); } $text = $parentNode->appendChild($tagRecord); }
public function get(Object $oObject, $aParams = array()) { if (isset($this->aParams['ToModuleAlias'])) { Core::import('Modules.' . $this->aParams['ToModuleAlias']); } $oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']); $aLocCriteria = array($this->aParams['Field'] => $oObject->getId()); if (!empty($aParams)) { if (isset($aParams['Criteria'])) { foreach ($aParams['Criteria'] as $key => $val) { $aLocCriteria[$key] = $val; } } } $nRelation = $oMapper->findStat('count', 'c', isset($this->aParams['FunctionParams']) ? $this->aParams['FunctionParams'] : '*', array('Criteria' => $aLocCriteria)); return $nRelation; }
/** * Processa o arquivo Webservice * * @return string * @throws Exception */ public function processamentoArquivo() { try { /** * Verifica o nome do arquivo */ if (!$this->sNomeArquivo) { $this->oModeloImportacao->setMensagemErro('E160'); } /** * Verifica se existe algum registro de usuário */ if (!is_object($this->oDadosUsuario)) { throw new Exception('Usuario não encontrado!', 157); } /** * Verifica se o usuário está autenticado */ if (!$this->autenticaUsuario($this->oDadosUsuario->getLogin())) { $this->oModeloImportacao->setMensagemErro('E157', 'Usuario: ' . $this->oDadosUsuario->getLogin()); } $this->oModeloImportacao->setArquivoCarregado($this->sCaminhoNomeArquivo); $oArquivoCarregado = $this->oModeloImportacao->carregar(); /** * Verifica se o modelo está válido e processa o arquivo de importação */ if ($oArquivoCarregado && !$this->oModeloImportacao->getErro() && $this->oModeloImportacao->validaArquivoCarregado()) { /** * Valida as regras de negócio e processa a importação */ $oImportacaoProcessamento = new Contribuinte_Model_ImportacaoArquivoProcessamento(); $oImportacaoProcessamento->setCodigoUsuarioLogado($this->oDadosUsuario->getId()); $oImportacaoProcessamento->setArquivoCarregado($oArquivoCarregado); /** * Processa a importação */ $oDadosImportacao = $oImportacaoProcessamento->processarImportacaoRps(); return $this->oModeloImportacao->processaSucessoWebService($oDadosImportacao); } else { return $this->oModeloImportacao->processaErroWebService($oArquivoCarregado->lote->numero); } } catch (Exception $oErro) { throw new Exception($oErro->getMessage(), $oErro->getCode()); } }
/** * Update #__joommark_stats (current sessions) * * @access protected * @return Exception object otherwise boolean true */ protected function updateStats() { // Create and populate an object. $StatsObject = new stdClass(); $StatsObject->session_id_person = $this->session->getId(); $StatsObject->nowpage = str_replace(JUri::getInstance()->base(), '', urldecode($this->app->input->post->getString('nowpage', null))); str_replace("11223344", "", "REGISTER 11223344 here"); $StatsObject->lastupdate_time = time(); $StatsObject->current_name = $this->userName; try { // Test if the session is open $query = $this->db->getQuery(true); $query->select($this->db->quoteName("session_id_person"))->from($this->db->quoteName("#__joommark_stats"))->where($this->db->quoteName("session_id_person") . " = " . $this->db->quote($StatsObject->session_id_person)); // Set the query and execute $this->db->setQuery($query); $exists = (bool) $this->db->loadResult(); if ($this->db->getErrorNum()) { // Todo throw new Exception(JText::sprintf('PLG_TRACKER_COM_JOOMMLAMARK_ERROR_READING_INSERTING_NEW_STAT', $this->db->getErrorMsg()), 'error', 'Server stats'); } // Insert the object into the #__joommark_serverstats table. Otherwise update the time tracker if (!$exists) { // Insert the object into the #__joommark_stats table. $result = JFactory::getDbo()->insertObject('#__joommark_stats', $StatsObject); if ($this->db->getErrorNum()) { // Todo throw new Exception(JText::sprintf('PLG_TRACKER_COM_JOOMMLAMARK_ERROR_READING_INSERTING_NEW_STAT', $this->db->getErrorMsg()), 'error', 'Server stats'); } } else { // In the case, that the session exists we have to update nowpage and lastupdate_time! // Todo or have we do this only on afterroute? $StatsObjectOnlyName = new stdClass(); $StatsObjectOnlyName->session_id_person = $this->session->getId(); $StatsObjectOnlyName->lastupdate_time = time(); $StatsObjectOnlyName->nowpage = str_replace(JUri::getInstance()->base(), '', urldecode($this->app->input->post->getString('nowpage', null))); $StatsObjectOnlyName->current_name = $this->userName; $result = $this->db->updateObject('#__joommark_stats', $StatsObjectOnlyName, 'session_id_person'); } } catch (Exception $e) { JFactory::getApplication()->enqueueMessage($e->getMessage()); // Todo special exeption handling } return true; }
/** * @param Object $obj * @param string|null $thumbnail * @return string */ public static function getViewPath($obj, $thumbnail = null) { switch ($obj) { case $obj instanceof \Crm\Model\Contract\File: if ($obj->getFileName()) { return '/media/contracts/' . $obj->getContractId() . '/' . $obj->getFileName(); } break; case $obj instanceof \Hrm\Model\Recruitment\Candidate: $filePath = DateBase::createFromFormat(DateBase::COMMON_DATE_FORMAT, $obj->getCreatedDate())->format('Ymd'); return '/media/hrm/candidate/' . $filePath . '/' . $obj->getFileName(); break; case $obj instanceof \Work\Model\TaskFile: $filePath = DateBase::createFromFormat(DateBase::COMMON_DATETIME_FORMAT, $obj->getCreatedDateTime())->format('Ymd'); return '/media/work/attachfile/' . $filePath . '/' . $obj->getTaskId() . '/' . $obj->getFileName(); break; case $obj instanceof \Work\Model\MeetingFile: $filePath = DateBase::createFromFormat(DateBase::COMMON_DATETIME_FORMAT, $obj->getCreatedDateTime())->format('Ymd'); return '/media/projects/meetings/' . $filePath . '/' . $obj->getMeetingId() . '/' . $obj->getFileName(); break; case $obj instanceof \Company\Model\AnnouncementFile: //return '/media/company/announcement/'.$obj->getOption('companyId').'/'.$obj->getAnnouncementId().'/'.$obj->getFileName(); if (!$obj->getFilePath()) { return '/media/announcement/temp/' . $obj->getAnnouncementId(); } else { return '/media/announcement/' . $obj->getFilePath() . '/' . $obj->getAnnouncementId(); } break; case $obj instanceof \Document\Model\DocumentFile: $filePath = DateBase::createFromFormat(DateBase::COMMON_DATETIME_FORMAT, $obj->getCreatedDateTime())->format('Ymd'); return '/media/document/documents/' . $filePath . '/' . $obj->getDocumentId() . '/' . $obj->getFileName(); break; case $obj instanceof \Idea\Model\File: $filePath = DateBase::createFromFormat(DateBase::COMMON_DATETIME_FORMAT, $obj->getCreatedDateTime())->format('Ymd'); return '/media/idea/' . $obj->getFilePath() . '/' . $obj->getIdeaId() . '/' . $obj->getFileName(); break; case $obj instanceof \User\Model\User: if (!$obj->getCreatedDateTime()) { return '/media/users/default/' . $obj->getId() . '/'; } $datePath = DateBase::toFormat($obj->getCreatedDateTime(), 'Ymd'); return '/media/user/' . $datePath . '/' . $obj->getId() . '/' . $obj->getAvatar(); break; } return ''; }
/** * Permet d'ajouter un objet en : * precisant dans $type son type "object", "category" ou "promotion" * dans $id_parent l'identifiant de la categorie ou l'identifiant de la promotion au dessus (c'est independant du type) * dans $step le numero de l'etape dans la promotion (ça commence à 1), pas applicable pour category ou object * en retour on a un CSV contenant case 0, l'etat de l'ajout (1 si ok, le numero de l'erreur si echec), case 1 l'id de l'ajout (0 si echec) * * la methode suppose que le stock est illimité * l'objet n'est pas unique * l'image est l'image par defaut * que la fundation est celle de fadmin * * @return String $retour * @param String $name * @param String $type * @param int $id_parent * @param int $step */ public function addObject($name, $type, $id_parent = NULL, $step = NULL) { $rtn = new ComplexData(); if ($type == "product") { $obj = new Object(0, $name, $type, -1, $this->Fundation->getId(), 1, 0, 0); $err = $obj->getState(); if (!is_null($id_parent) && $err == 1) { if (!is_null($step)) { $obj_promo = new Object($id_parent); if ($obj_promo->getState() != 1) { $err = 471; } else { $rtn_promo = $obj_promo->addPromoChild($obj->getId(), $step); if ($rtn_promo != 1) { $err = 400; } } } else { $rtn_parent = $obj->addParent($id_parent); if ($rtn_parent == 0) { $err = 471; } } } $rtn->addLine(array($err, $obj->getId())); } else { if ($type == "category") { $obj = new Object(0, $name, $type, -1, $this->Fundation->getId(), 1, 0, 0); $err = $obj->getState(); if (!is_null($id_parent) && $err == 1) { if (!is_null($step)) { $obj_promo = new Object($id_parent); if ($obj_promo->getState() != 1) { $err = 471; } else { $rtn_promo = $obj_promo->addPromoChild($obj->getId(), $step); if ($rtn_promo != 1) { $err = 400; } } } else { $rtn_parent = $obj->addParent($id_parent); if ($rtn_parent == 0) { $err = 471; } } } $rtn->addLine(array($err, $obj->getId())); } else { if ($type == "promotion") { $obj = new Object(0, $name, $type, -1, $this->Fundation->getId(), 1, 0, 0); $err = $obj->getState(); if (!is_null($id_parent) && $err == 1) { if (!is_null($step)) { $obj_promo = new Object($id_parent); if ($obj_promo->getState() != 1) { $err = 471; } else { $rtn_promo = $obj_promo->addPromoChild($obj->getId(), $step); if ($rtn_promo != 1) { $err = 400; } } } else { $rtn_parent = $obj->addParent($id_parent); if ($rtn_parent == 0) { $err = 471; } } } $rtn->addLine(array($err, $obj->getId())); } else { $rtn->addLine(array("470", "0")); } } } return $rtn->csvArrays(); }
/** * Funcion para iniciar sesion * * @author Diego Malagón <*****@*****.**> * @param Object $usuario entidad usuario * @param array $params parametros adicionales para guardar en sesion */ public function login($usuario, $params = array()) { $sess_user = array('id' => $usuario->getId(), 'usuarioNombre' => $usuario->getUsuarioNombre(), 'usuarioApellido' => $usuario->getUsuarioApellido(), 'usuarioEmail' => $usuario->getUsuarioEmail(), 'usuarioFacebookid' => $usuario->getUsuarioFacebookid(), 'usuarioImagen' => $usuario->getUsuarioImagen(), 'rolId' => $usuario->getRol()->getId()); $sess_permissions = $this->getPermisosUsuario($usuario->getId()); $this->session->set('sess_user', $sess_user); $this->session->set('sess_permissions', $sess_permissions); if (count($params) > 0) { $this->session->set('sess_parameters', $params); } }
/** * Insert a new Record * * @param Object $entity Entity * * @return Object */ public function insertRecord($entity) { return $this->find($entity->getId()); }
/** * Method addRowLoadFromSqlDataView * @access private * @param mixed $row * @param mixed $list_attribute * @param mixed $list_attribute_type * @param mixed $key_attributes * @param mixed $ind * @param boolean $is_delete_action [default value: false] * @param double $line_nb [default value: 0] * @return boolean * @since 1.1.6 */ private function addRowLoadFromSqlDataView($row, $list_attribute, $list_attribute_type, $key_attributes, $ind, $is_delete_action = false, $line_nb = null) { if ($this->from_sql_data_view_delete) { // create delete button if not already exists $bnt_del_id = $this->id . "_btndel__ind_" . $ind; $delete_pic = $this->getPage()->getObjectId($bnt_del_id); if ($delete_pic == null) { $delete_pic = new Picture("img/wsp-admin/delete_16.png", 16, 16, 0, Picture::ALIGN_ABSMIDDLE); $delete_pic->setId($bnt_del_id); $delete_pic->onClickJs("if (!confirm('" . __(TABLE_CONFIME_DEL_ROW) . "')) { return false; }"); $delete_pic->onClick($this->getPage(), "onChangeTableFromSqlDataView")->setAjaxEvent()->disableAjaxWaitMessage(); } } // create row $row_table = new RowTable(); $row_table->setId($this->id . "_row_" . $ind); for ($i = 0; $i < sizeof($list_attribute); $i++) { // get field properties if (is_array($this->from_sql_data_view_properties[$list_attribute[$i]])) { $attribute_properties = $this->from_sql_data_view_properties[$list_attribute[$i]]; } else { $attribute_properties = array(); } // get property display if (isset($attribute_properties["display"]) && $attribute_properties["display"] == false) { continue; } // get property update $is_update_ok = true; if (isset($attribute_properties["update"]) && $attribute_properties["update"] == false) { $is_update_ok = false; } if ($this->from_sql_data_view_update && !in_array($list_attribute[$i], $key_attributes) && $is_update_ok) { $row_value = $row->getValue($list_attribute[$i]); if (gettype($row_value) == "object" && method_exists($row_value, "render")) { $row_value = $row_value->render(); } $edit_pic = new Picture("wsp/img/edit_16x16.png", 16, 16); $row_obj = new Object($edit_pic, trim($row_value) == "" ? " " : utf8encode($row_value)); $row_obj->setId($this->id . "_" . $list_attribute[$i] . "_obj_" . $ind)->setStyle("cursor:pointer;border:1px solid gray;"); $input_obj = $this->createDbAttributeObject($row, $list_attribute, $list_attribute_type, $i, $ind, $key_attributes); if (get_class($input_obj) == "ComboBox") { // Get foreign key value $row_obj->emptyObject(); $value = $input_obj->getText(); $row_obj->add($edit_pic, trim($value) == "" ? " " : $value); } else { if (get_class($input_obj) == "Calendar") { $row_obj->emptyObject(); $value = $input_obj->getValueStr(); $row_obj->add($edit_pic, trim($value) == "" ? " " : $value); $row_table->setNowrap(); } } $row_obj_input = new Object($input_obj); $row_obj_input->setId($this->id . "_" . $list_attribute[$i] . "_input_obj_" . $ind); $cancel_pic = new Picture("wsp/img/cancel_12x12.png", 12, 12); $cancel_pic->setId($this->id . "_img_" . $ind . "_cancel_" . $list_attribute[$i]); $cancel_pic->onClickJs("\$('#" . $row_obj->getId() . "').css('display', 'inline');\$('#" . $row_obj_input->getId() . "').hide();" . ($this->from_sql_data_view_add_button != null ? "\$('#" . $this->from_sql_data_view_add_button->getId() . "').button({ disabled: false });" : "")); $cancel_pic_obj = new Object($cancel_pic); $row_obj_input->add($cancel_pic_obj->forceSpanTag()->setStyle("position:absolute;")); if (!$this->getPage()->isAjaxPage() || $is_delete_action || $this->from_sql_data_view_reload_pic != null && $this->from_sql_data_view_reload_pic->isClicked() || $this->from_sql_data_view_add_button != null && $this->from_sql_data_view_add_button->isClicked()) { $this->getPage()->addObject(new JavaScript("\$(document).ready(function() { \$('#" . $row_obj_input->getId() . "').hide(); });")); } $row_obj->onClickJs("\$('#" . $row_obj->getId() . "').hide();\$('#" . $row_obj_input->getId() . "').show();" . ($this->from_sql_data_view_add_button != null ? "\$('#" . $this->from_sql_data_view_add_button->getId() . "').button({ disabled: true });" : "")); $row_table->add(new Object($row_obj, $row_obj_input)); // get properties align if (isset($attribute_properties["align"])) { $row_table->setColumnAlign($i + 1, $attribute_properties["align"]); } } else { $value = $row->getValue($list_attribute[$i]); if (isset($this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj'])) { $input_obj_tmp = $this->from_sql_data_view_properties[$list_attribute[$i]]['cmb_obj']; $input_obj_tmp->setValue($value); $value = $input_obj_tmp->getText(); } if (get_class($value) == "DateTime") { $value = $value->format("Y-m-d"); } $row_table->add(utf8encode($value)); } } if ($this->from_sql_data_view_delete) { $row_table->add($delete_pic); } else { if ($this->from_sql_data_view_insert) { $row_table->add(); } } if ($is_table_defined_style) { $row_table->setBorderPredefinedStyle($this->class); } if ($this->is_advance_table) { if (isset($line_nb) && $line_nb !== null) { $row_table->setRowClass($line_nb % 2 == 0 ? "odd" : "even"); } else { if (is_numeric($ind)) { $row_table->setRowClass($ind % 2 == 0 ? "odd" : "even"); } else { $row_table->setRowClass("even"); } } } $this->addRow($row_table); }
/** * Verifies and saves the ID for a foreign key object * * Caches the object in a private variable and sets * the ID value in the data * * @param string $class Fully namespaced classname * @param string $field Name of field to set * @param Object $object Value to set */ protected function setForeignKeyObject($class, $field, $object) { if ($object instanceof $class) { $var = preg_replace('/_id$/', '', $field); $this->data[$field] = $object->getId(); $this->{$var} = $object; } else { throw new \Exception('Object does not match the given class'); } }
public function createExamples($ind) { $table_box = new Table(); $table_box->setWidth(250)->setDefaultAlign(RowTable::ALIGN_LEFT); $table_box->addRow(); $body_obj = new Object(); $body_obj->setAlign(Object::ALIGN_CENTER); //->setId("id_body_obj")->setStyle("padding:5px;background:".$this->background_body->getValue().";"); $text_obj = new Object(__(TEXT_ON_BODY)); $body_obj->add($text_obj->setId("id_body_text"), "<br/>"); $link_obj = new Object(new Link("javascript:void(0);", Link::TARGET_BLANK, __(LINK_ON_BODY))); $body_obj->add($link_obj->setId("id_body_link"), "<br/>"); $body_obj->add($this->text_link_note_obj, "<br/>"); $table_box->addRow($body_obj); $table_box->addRow(); $table_box->addRow(); $button_1 = new Button($this); $button_1->setWidth(245); $table_box->addRow($button_1->setValue("Button [style jquery]")); $table_box->addRow(); $tabs = new Tabs("tab-sample"); $tabs->addTab("Tab1", ""); $tabs->addTab("Tab2", ""); $tabs->addTab("Tab3", ""); $table_box->addRow($tabs); $table_box->addRow(); $table_box->addRow(); $table_box->addRow(); $table_box->addRow(); $table_box->addRow(); $dialogbox = new DialogBox(__(DIALOGBOX_TITLE), __(DIALOGBOX_CONTENT)); $dialogbox->setWidth(245)->activateOneInstance()->setPosition(""); $dialogbox_link = new Object(new Link($dialogbox, Link::TARGET_NONE, __(VIEW_DIALOGBOX))); $table_box->addRow($dialogbox_link->setId("id_dialogbox_link")); $dialogbox->setPositionX("\$('#" . $dialogbox_link->getId() . "').position().left-f_scrollLeft()"); $dialogbox->setPositionY("\$('#" . $dialogbox_link->getId() . "').position().top-f_scrollTop()-70"); $this->addObject(clone $dialogbox); $table_box->addRow(); $table_box->addRow(); $table_box->addRow(); $table_box->addRow(); $table_box->addRow(); $table_box->addRow(); $style1_box_text = new Box("text", false, $this->current_style_val, $this->current_style_val, "", "box_text_" . $this->current_style_val, 245); if ($this->background_picture_1->getValue() != "") { $style1_box_text->forceBoxWithPicture(true, $this->border_table_1->getValue()); } else { $style1_box_text->forceBoxWithPicture(false); } $table_box->addRow($style1_box_text->setContent("Box Object [<a href=\"javascript:void(0);\">style " . $this->current_style_val . "</a>]")); $style1_box = new Box("link", false, $this->current_style_val, $this->current_style_val, "javascript:void(0);", "box_" . $this->current_style_val, 245); if ($this->background_picture_1->getValue() != "") { $style1_box->forceBoxWithPicture(true, $this->border_table_1->getValue()); } else { $style1_box->forceBoxWithPicture(false); } $style1_box->setShadow(true); $table_box->addRow($style1_box->setContent("Box Object [<a href=\"javascript:void(0);\">style " . $this->current_style_val . "</a>]")); $style1_box = new RoundBox($this->current_style_val, "round_box_" . $this->current_style_val, 245); $style1_box->setShadow(true); if ($this->background_picture_1->getValue() != "") { $style1_box->forceBoxWithPicture(true, $this->border_table_1->getValue()); } else { $style1_box->forceBoxWithPicture(false); } $table_box->addRow($style1_box->setContent("RoundBox Object<br/>[style " . $this->current_style_val . "]")); $table_box->addRow(); if (!defined('DEFINE_STYLE_BORDER_TABLE_' . $this->current_style_val)) { define('DEFINE_STYLE_BORDER_TABLE_' . $this->current_style_val, $this->border_table_1->getValue()); } $table = new Table(); $table->setId("table_sample")->setWidth(245); $table->addRowColumns("header1", "header2", "header3")->setHeaderClass($this->current_style_val); $table->addRowColumns("cel 1-1", "cel 1-2", "cel 1-3")->setId("table_tr_sample")->setBorderPredefinedStyle($this->current_style_val)->setAlign(RowTable::ALIGN_CENTER); $table_box->addRow($table); return $table_box; }
/** * Return value of 'id' field * * @access public * @param void * @return integer */ function getId() { return $this->object->getId(); }
/** * Set group * * @param Object $group * @return self */ public function setGroup($group) { $this->group = $group; $this->groupId = $group->getId(); return $this; }
/** * deleteProductCheck If seller delete their product then product will assign to another seller * @param Object $observer Deleting product information * @var Int $productId eleting product id * @var Object $collection Assign product collection object * @var Object $collectionpro Marketplace Collection object * @var Array $data Assign product details * @var Object $stockItem catalog Product stock item * @var Object $_product catalog product model object * @var Object $savedStock saved catalog Product stock item */ public function deleteProductCheck($observer) { $productId = $observer->getId(); $collection = Mage::getModel('mpassignproduct/mpassignproduct')->getCollection()->addFieldToFilter('product_id', array('eq' => $productId))->addFieldToFilter('qty', array('gt' => 0)); $collection->setOrder("price", "ASC"); if (count($collection) > 0) { foreach ($collection as $assignproduct) { $collectionpro = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid', array('eq' => $productId)); foreach ($collectionpro as $row) { $row->setUserid($assignproduct->getSellerId()); $row->save(); $data = Mage::getModel('mpassignproduct/mpassignproduct')->getAssignProDetails($productId); $_product = Mage::getModel('catalog/product')->load($productId); $_product->setPrice($assignproduct->getPrice()); $_product->save(); $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId); $stockItem->setProductId($productId)->setStockId(1); $savedStock = $stockItem->save(); $stockItem->load($savedStock->getId())->setQty($data['assignqty'])->save(); $stockItem->setData('is_in_stock', 1); $savedStock = $stockItem->save(); } Mage::getSingleton('customer/session')->setIsAssing($assignproduct->getMpassignproductId()); $assignproduct->delete(); break; } } else { Mage::getSingleton('customer/session')->setIsAssing(0); } }
/** * Get uploaded files by client * @param Object $user_profile * @Return Propel Object */ private function clientUploadedFiles($user_profile) { $profile_id = $user_profile->getProfile()->getId(); $client = ProfilePeer::retrieveByPk($profile_id); $client_name = $client->getsfGuardUserRelatedByUserId()->getUsername(); $c = new Criteria(); $c->add(CompanyUsersPeer::USER_ID, $user_profile->getId()); $company = CompanyUsersPeer::doSelectOne($c); if ($company) { $company_name = $company->getCompany()->getName(); } else { $company_name = ''; } $c = new Criteria(); $c->add(pmProjectObjectsPeer::TYPE, 'clientfile'); $c->add(pmProjectObjectsPeer::MODULE, 'resources'); $c->add(pmProjectObjectsPeer::VARCHAR_FIELD_1, $company_name . $client_name); $c->addAscendingOrderByColumn(pmProjectObjectsPeer::PJ_LOTNO); $r = pmProjectObjectsPeer::doSelect($c); $this->clientcompany = $company_name . $client_name; return $r; }
/** * Move uploaded image into respective folder * * @param Object $objUser * @param String $tmpImageName * @param String $name * @param Boolean $profilePic * * @return String */ protected static function moveUploadedImageInToPlace($objUser, $tmpImageName, $name, $profilePic = false) { static $objImage, $arrSettings; if (empty($objImage)) { $objImage = new \ImageManager(); } if (empty($arrSettings)) { $arrSettings = array(); $arrSettings['profile_thumbnail_pic_width']['value'] = 80; $arrSettings['profile_thumbnail_pic_height']['value'] = 60; $arrSettings['profile_thumbnail_scale_color']['value'] = ''; $arrSettings['profile_thumbnail_method']['value'] = ''; $arrSettings['max_profile_pic_width']['value'] = 160; $arrSettings['max_profile_pic_height']['value'] = 160; } $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $imageRepo = $profilePic ? $cx->getWebsiteImagesAccessProfilePath() : $cx->getWebsiteImagesAccessPhotoPath(); $index = 0; $imageName = $objUser->getId() . '_' . $name; while (file_exists($imageRepo . '/' . $imageName)) { $imageName = $objUser->getId() . '_' . ++$index . '_' . $name; } if (!$objImage->loadImage($tmpImageName)) { return false; } // resize image if its dimensions are greater than allowed if ($objImage->orgImageWidth > $arrSettings['max_profile_pic_width']['value'] || $objImage->orgImageHeight > $arrSettings['max_profile_pic_height']['value']) { $ratioWidth = $arrSettings['max_profile_pic_width']['value'] / $objImage->orgImageWidth; $ratioHeight = $arrSettings['max_profile_pic_height']['value'] / $objImage->orgImageHeight; if ($ratioHeight > $ratioWidth) { $newWidth = $objImage->orgImageWidth * $ratioWidth; $newHeight = $objImage->orgImageHeight * $ratioWidth; } else { $newWidth = $objImage->orgImageWidth * $ratioHeight; $newHeight = $objImage->orgImageHeight * $ratioHeight; } if (!$objImage->resizeImage($newWidth, $newHeight, 100)) { return false; } // copy image to the image repository if (!$objImage->saveNewImage($imageRepo . '/' . $imageName)) { return false; } } else { if (!copy($tmpImageName, $imageRepo . '/' . $imageName)) { return false; } } return $imageName; }
/** * @param Object $field * @param String $order * @return ArrayObject Options of field */ public function getOptionsOfField($field, array $order) { return $this->repository->findBy(['field_id' => $field->getId()], [$order, null, null]); }