public function loadData($pid, $name, $tmpDir)
 {
     // Upload to WebDav
     $webDav = new WebDav($this->gdClient->getUsername(), $this->gdClient->getPassword(), $this->gdClient->getUserUploadUrl());
     $dimensionName = Identifiers::getIdentifier($name);
     $tmpFolderNameDimension = "{$pid}-{$dimensionName}-" . uniqid();
     $tmpFolderDimension = $tmpDir . '/' . Identifiers::getIdentifier($name);
     mkdir($tmpFolderDimension);
     $timeDimensionManifest = self::getDataLoadManifest($dimensionName);
     file_put_contents("{$tmpFolderDimension}/upload_info.json", $timeDimensionManifest);
     copy(__DIR__ . '/time-dimension.csv', "{$tmpFolderDimension}/{$dimensionName}.csv");
     $webDav->createFolder($tmpFolderNameDimension);
     $webDav->upload("{$tmpFolderDimension}/upload_info.json", $tmpFolderNameDimension);
     $webDav->upload("{$tmpFolderDimension}/{$dimensionName}.csv", $tmpFolderNameDimension);
     // Run ETL task of time dimensions
     try {
         $this->gdClient->getDatasets()->loadData($pid, $tmpFolderNameDimension);
     } catch (Exception $e) {
         $debugFile = "{$tmpFolderDimension}/{$pid}-etl.log";
         $logSaved = $webDav->saveLogs($tmpFolderDimension, $debugFile);
         if ($logSaved) {
             $data = file_get_contents($debugFile);
             if ($data) {
                 $data = json_decode($data, true);
                 if ($data) {
                     $e = new Exception(json_decode(file_get_contents($debugFile), true), $e->getCode(), $e);
                 }
             }
         }
         throw $e;
     }
 }
Example #2
0
 /**
  * Tests the `Client` constructor.
  */
 public function testConstructor()
 {
     $client = new Client(['username' => 'anonymous', 'password' => 'secret']);
     $this->assertEquals('secret', $client->getPassword());
     $this->assertEquals('anonymous', $client->getUsername());
     $this->assertSame($client, $client->setPassword(''));
     $this->assertEmpty($client->getPassword());
 }
Example #3
0
 /**
  * Modify a client saved in the database.
  *
  * @param Client $client
  * @return integer
  */
 public function editClient(Client $client)
 {
     $mcrypt = new MCrypt();
     $sql = "UPDATE client \n\t\t\tSET id_client = '" . $client->getIdClient() . "', client_name = '" . replaceCharacters($client->getClientName()) . "', agent = '" . replaceCharacters($client->getAgent()) . "', address = '" . replaceCharacters($client->getAddress()) . "', phone = '" . $client->getPhone() . "', email = '" . $client->getEmail() . "', website = '" . $client->getWebsite() . "', user = '******', password = '******' WHERE id_client = '" . $client->getIdClient() . "'";
     return DB::query($sql);
 }
Example #4
0
    /**
     * Renderize the view.
     *
     * @return null
     */
    public function render(Client $client)
    {
        ?>
  
    
    <p> 
        <?php 
        echo REQUIRED_FIELDS_TEXT;
        ?>
    </p>

	<form action="<?php 
        echo $this->generateURL('client', 'edit', $client->getIdClient());
        ?>
" method="post">
    	
        <fieldset>
        
            <div class="row">
            
                <div class="col-md-6">	
                
                	<div>
                        <label for="client_name">
                            Nombre <small>(*)</small>
                        </label>
                        <input name="client_name" type="text" required value="<?php 
        echo $client->getClientName();
        ?>
" /> 
                    </div>

                    <div>
                        <label for="agent">
                            Representante <small>(*)</small>
                        </label>
                        <input name="agent" type="text" required value="<?php 
        echo $client->getAgent();
        ?>
" /> 
                    </div>

                    <div>
                        <label for="address">
                            Direcci&oacute;n <small>(*)</small>
                        </label>
                        <input name="address" type="text" required value="<?php 
        echo $client->getAddress();
        ?>
" /> 
                    </div>

                    <div>
                        <label for="phone">
                            Tel&eacute;fono <small>(*)</small>
                        </label>
                        <input name="phone" type="tel" required value="<?php 
        echo $client->getPhone();
        ?>
" /> 
                    </div>
                    
                </div>
               
                <div class="col-md-6">	

                    <div>
                        <label for="email">
                            Correo electr&oacute;nico <small>(*)</small>
                        </label>
                        <input name="email" type="email" required value="<?php 
        echo $client->getEmail();
        ?>
" /> 
                    </div>

                    <div>
                        <label for="website">
                            Sitio web
                        </label>
                        <input name="website" type="url" value="<?php 
        echo $client->getWebsite();
        ?>
" /> 
                    </div>

                    <div>
                        <label for="user">
                            Usuario <small>(*)</small>
                        </label>
                        <input name="user" type="text" required value="<?php 
        echo $client->getUser();
        ?>
" /> 
                    </div>

                    <div>
                        <label for="email">
                            Contrase&ntilde;a <small>(*)</small>
                        </label>
                        <input name="password" type="text" required value="<?php 
        echo $client->getPassword();
        ?>
" /> 
                    </div>

                    <div>
                        <input type="submit" value="Modificar" />
                    </div>
                
                </div>
            
            </div>
            
    	</fieldset>
        
    </form>

<?php 
    }