Ejemplo n.º 1
0
    /**
     * Renderize the view.
     *
     * @return null
     */
    public function render(array $providerCategories, Provider $provider)
    {
        ?>
  
    
    <p> 
        <?php 
        echo REQUIRED_FIELDS_TEXT;
        ?>
    </p>

	<form action="<?php 
        echo $this->generateURL('provider', 'edit', $provider->getIdProvider());
        ?>
" method="post">
    	
        <fieldset>
        
            <div class="row">
            
                <div class="col-md-6">  

                    <div>
                        <label for="id_provider_category">
                            Categor&iacute;a <small>(*)</small>
                        </label>
                        <select name="id_provider_category" required> 
                            <option value="">
                                Seleccionar
                            </option>
                            <?php 
        foreach ($providerCategories as $providerCategory) {
            if ($provider->getIdProviderCategory() === $providerCategory->getIdProviderCategory()) {
                ?>
                            <option value="<?php 
                echo $providerCategory->getIdProviderCategory();
                ?>
" selected>
                                <?php 
                echo $providerCategory->getCategoryName();
                ?>
                            </option>
                            <?php 
            } else {
                ?>
                            <option value="<?php 
                echo $providerCategory->getIdProviderCategory();
                ?>
">
                                <?php 
                echo $providerCategory->getCategoryName();
                ?>
                            </option>
                            <?php 
            }
        }
        ?>
                        </select>
                    </div>

                    <div>
                        <label for="provider_name">
                            Nombre <small>(*)</small>
                        </label>
                        <input name="provider_name" type="text" required value="<?php 
        echo $provider->getProviderName();
        ?>
" /> 
                    </div>

                    <div>
                        <label for="location">
                            Ubicaci&oacute;n <small>(*)</small>
                        </label>
                        <input name="location" type="text" required value="<?php 
        echo $provider->getLocation();
        ?>
" /> 
                    </div>

                </div>
               
                <div class="col-md-6">  

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

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

<?php 
    }
Ejemplo n.º 2
0
 /**
  * Modify a provider saved in the database.
  *
  * @param Provider $provider
  * @return integer
  */
 public function editProvider(Provider $provider)
 {
     $sql = "UPDATE provider \n\t\t\tSET id_provider_category = '" . $provider->getIdProviderCategory() . "', provider_name = '" . replaceCharacters($provider->getProviderName()) . "', location = '" . replaceCharacters($provider->getLocation()) . "', phone = '" . $provider->getPhone() . "', website = '" . $provider->getWebsite() . "' WHERE id_provider = '" . $provider->getIdProvider() . "'";
     return DB::query($sql);
 }