Beispiel #1
0
 function RentabilidadeReal($ano, $mes, $dia, $user_id)
 {
     $compra_array = array();
     $venda_array = array();
     $c = 0;
     $v = 0;
     $l = 1;
     //compra
     $SQLcompras = sprinft("SELECT * FROM sis_compra WHERE CAUS_NM_ID= %s ORDER BY COAT_TX_ID", $user_id);
     $SQL_compras_rcs = mysql_query($SQLcompras, SAINP) or die('Could not select the database: ' . mysql_error());
     while ($row_compras = mysql_fetch_array($SQL_compras_rcs)) {
         if ($compra_array[$l]['ativo'] == $compra_array[$l - 1]['ativo']) {
             $compra_array[$c]['ativo'] = $row_compras[$c]['COAT_TX_ID'];
             $compra_array[$c]['total'] = $compra_array[$c]['total'] + $row_compras[$l]['COMP_NM_Acoes'] * $row_compras[$l]['COMP_VL_Preco'] + $row_compras[$l]['COMP_VL_Emolumentos'] + $row_compras[$l]['COMP_VL_Corretagem'];
             $l++;
         } else {
             $l++;
             $c++;
         }
     }
     //venda
     $SQLvendas = sprinft("SELECT * FROM sis_venda WHERE CAUS_NM_ID= %s", $user_id);
     $SQL_vendas_rcs = mysql_query($SQLvendas, SAINP) or die('Could not select the database: ' . mysql_error());
     while ($row_vendas = mysql_fetch_array($SQL_vendas_rcs)) {
         if ($venda_array[$l]['ativo'] == $venda_array[$l - 1]['ativo']) {
             $venda_array[$v]['ativo'] = $row_vendas[$l]['COAT_TX_ID'];
             $venda_array[$v]['total'] = $row_vendas[$l]['VEND_NM_Acoes'] * $row_vendas[$l]['VEND_VL_Preco'] + $row_vendas[$l]['VEND_VL_Emolumentos'] + $row_vendas[$l]['VEND_VL_Corretagem'];
             $l++;
         } else {
             $l++;
             $v++;
         }
     }
 }
Beispiel #2
0
 function ajaxUpdateForms()
 {
     global $userMeta;
     $userMeta->verifyNonce();
     $error = null;
     $data = array();
     if (isset($_POST['forms'])) {
         foreach ($_POST['forms'] as $formID => $formData) {
             if (is_array($formData['fields'])) {
                 foreach ($formData['fields'] as $fieldID => $fieldKey) {
                     if ($fieldID >= $formData['field_count']) {
                         unset($formData['fields'][$fieldID]);
                     }
                 }
             }
             /*if( $formData['field_count'] ) {
                   foreach( $formData['fields'] as $fieldID => $fieldKey ){
                       if( $fieldID >= $formData['field_count'] )
                           unset( $formData['fields'][$fieldID] );
                   }
               } */
             unset($formData['field_count']);
             if (!$formData['form_key']) {
                 $error[] = __('All form keys are required!', $userMeta->name);
             }
             if (isset($data[$formData['form_key']])) {
                 $error[] = sprinft(__('Form key should be unique. "%s" is duplicated!', $userMeta->name), $formData['form_key']);
             }
             $data[$formData['form_key']] = $formData;
         }
     }
     if ($error) {
         echo $userMeta->showError($error);
         die;
     }
     $data = $userMeta->arrayRemoveEmptyValue($data);
     $data = apply_filters('user_meta_pre_configuration_update', $data, 'forms_editor');
     $userMeta->updateData('forms', $data);
     echo $userMeta->showMessage(__('Form Successfully saved.', $userMeta->name));
     die;
 }
Beispiel #3
0
 public function AuthByCookie($cookie)
 {
     if (!empty($cookie)) {
         $userRes = $this->mysqlQuery(sprinft("SELECT * FROM `%saccounts` WHERE `key` = '%s' LIMIT 1", $this->xf->config['MySQL']['prefix'], $this->xf->mysqlReal_escape_string($cookie)));
         if ($userRes->num_rows) {
             $dbUser = $userRes->fetch_assoc();
             $this->isAuthed = true;
             $this->isFormAuthed = false;
             $this->username = $dbUser['username'];
             $this->dbID = $dbUser['id'];
             $this->key = $dbUser['key'];
             $this->_flags();
             return $this->isAuthed;
         }
     }
     $this->isAuthed = false;
     $this->isFormAuthed = false;
     return $this->isAuthed;
 }
Beispiel #4
0
 /**
  * Upload a new file to the webserver.
  * @param 	$file		List of file values.
  * @param 	$folderId 	Folder to move uploaded file to.
  * @param	$filetypes	Filetypes to allow for this upload (not required).
  * @return errors object.
  */
 function uploadFile($file, $folderId, $filetypes = array())
 {
     global $dbi, $errors;
     global $lFileUploadFiles;
     // Get file attributes
     $name = $file["name"];
     $size = $file["size"];
     $tmp_name = $file["tmp_name"];
     $type = $file["type"];
     // Validate file data
     if (!empty($name)) {
         if (sizeof($filetypes) > 0) {
             if (!$this->isFiletypeSupported($file, $filetypes)) {
                 $errors->addError("file", sprinft($lFileUploadFiles["FileTypeNotAllowed"], $name));
             }
         }
         // Check if file already exists
         if ($this->fileExists($name, $folderId)) {
             for ($i = 1; $i < 10; $i++) {
                 if (!$this->fileExists($this->getFilename($name) . "-{$i}." . $this->getFileExtension($name), $folderId)) {
                     $name = $this->getFilename($name) . "-{$i}." . $this->getFileExtension($name);
                     $unique = true;
                     break;
                 }
             }
         } else {
             $unique = true;
         }
         if ($unique) {
             // Insert metadata into database
             $dbi->query("INSERT INTO " . fileTableName . "(name,folderId,type,size) VALUES(" . $dbi->quote($name) . "," . $dbi->quote($folderId) . "," . $dbi->quote($type) . "," . $dbi->quote($size) . ")");
             // Get identifier
             $id = $dbi->getInsertId();
             if (!empty($id)) {
                 // Move file to correct location
                 if (!move_uploaded_file($tmp_name, filePath . "/" . $id . "." . $this->getFileExtension($name))) {
                     // Delete file from database
                     $dbi->query("DELETE FROM " . fileTableName . " WHERE id=" . $dbi->quote($id));
                     // Save error message
                     $errors->addError("file", "The file \"" . $name . "\" could not be uploaded to the folder.");
                 }
             }
         } else {
             // Save error message
             $errors->addError("file", sprinft($lFileUploadFiles["FileAlreadyExists"], $name));
         }
     }
     return $errors;
 }
Beispiel #5
0
 /**
  * Respond to format
  *
  * Sets to which formats the action will respond.
  * It accepts a list of methods that will be called if the
  * request matches the format.
  *
  * Example:
  *   $this->respondTo(array(
  *      'html',
  *      'xml' => array(
  *          '_some_method' => array($param_1, $param_2),
  *          '_render'      => array(array('xml' => $obj), array('status' => 403))
  *      )
  *  ));
  *
  * Note: The way this function receives its parameters is because we can't use Closures,
  * due to the protected visibility of the methods such as _render().
  *
  * In the case above, it's stated that the action is able to respond to html and xml.
  * In the case of an html request, no further action is needed to respond; therefore,
  * we just list the 'html' format there.
  * In the case of an xml request, the controller will call _some_method($param_1, $param_2)
  * then it will call the _render() method, giving it the variable with which it will respond
  * (an ActiveRecord_Base object, an array, etc), and setting the status to 403.
  * Any request with a format not specified here will be responded with a 406 HTTP status code.
  *
  * By default all requests respond to xml, json and html. If the action receives a json
  * request for example, but no data is set to respond with, the dispatcher will look for
  * the .$format.php file in the views (in this case, .json.php). If the file is missing,
  * which actually is expected to happen, a Dispatcher_TemplateMissing exception will be
  * thrown.
  *
  * @see respond_with()
  */
 public function respondTo($responses)
 {
     $format = $this->request()->format();
     foreach ($responses as $fmt => $action) {
         if (is_int($fmt)) {
             $fmt = $action;
             $action = null;
         }
         if ($fmt !== $format) {
             continue;
         }
         if ($action) {
             if (!$action instanceof Closure) {
                 throw new Exception\InvalidArgumentException(sprinft('Only closure can be passed to respondTo, %s passed', gettype($action)));
             }
             $action();
         } else {
             $action = true;
         }
         $this->_respond_action = $action;
         return;
     }
     /**
      * The request format is not acceptable.
      * Set to render nothing with 406 status.
      */
     Rails::log()->message("406 Not Acceptable");
     $this->render(array('nothing' => true), array('status' => 406));
 }