/[dolibarr]/dolibarr/htdocs/compta/facture/apercu.php
ViewVC logotype

Diff of /dolibarr/htdocs/compta/facture/apercu.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by eldy, Fri Sep 2 20:07:21 2005 UTC revision 1.25 by eldy, Sat Sep 3 12:47:56 2005 UTC
# Line 66  $html = new Form($db); Line 66  $html = new Form($db);
66  /* *************************************************************************** */  /* *************************************************************************** */
67    
68  if ($_GET["facid"] > 0)  if ($_GET["facid"] > 0)
69  {        {
70    $fac = New Facture($db);      $fac = New Facture($db);
71    if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0)      if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0)
72      {          {
73        $soc = new Societe($db, $fac->socidp);          $soc = new Societe($db, $fac->socidp);
74        $soc->fetch($fac->socidp);          $soc->fetch($fac->socidp);
75        $author = new User($db);          $author = new User($db);
76        $author->id = $fac->user_author;          $author->id = $fac->user_author;
77        $author->fetch();          $author->fetch();
78          
79        $h = 0;          $h = 0;
80          
81        $head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;          $head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
82        $head[$h][1] = $langs->trans("CardBill");          $head[$h][1] = $langs->trans("CardBill");
83        $h++;          $h++;
84        $head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$fac->id;          $head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$fac->id;
85        $head[$h][1] = $langs->trans("Preview");          $head[$h][1] = $langs->trans("Preview");
86        $hselected = $h;          $hselected = $h;
87        $h++;          $h++;
88    
89        if ($fac->mode_reglement == 3)          if ($fac->mode_reglement_code == 'PRE')
90          {          {
91            $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$fac->id;              $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$fac->id;
92            $head[$h][1] = $langs->trans("StandingOrders");              $head[$h][1] = $langs->trans("StandingOrders");
93            $h++;              $h++;
94          }          }
95    
96        $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id;          $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id;
97        $head[$h][1] = $langs->trans("Note");          $head[$h][1] = $langs->trans("Note");
98        $h++;                $h++;
99        $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id;          $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id;
100        $head[$h][1] = $langs->trans("Info");          $head[$h][1] = $langs->trans("Info");
101        $h++;                $h++;
102          
103        dolibarr_fiche_head($head, $hselected, $langs->trans("Bill")." : $fac->ref");          dolibarr_fiche_head($head, $hselected, $langs->trans("Bill")." : $fac->ref");
104    
105          
106        /*          /*
107         *   Facture          *   Facture
108         */          */
       print '<table class="border" width="100%">';  
       print '<tr><td>'.$langs->trans("Company").'</td>';  
       print '<td colspan="5">';  
       print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';  
       print '</tr>';  
         
       // Dates      
       print '<tr><td>'.$langs->trans("Date").'</td>';  
       print '<td colspan="3">'.dolibarr_print_date($fac->date,"%A %d %B %Y").'</td>';  
       print '<td>'.$langs->trans("DateClosing").'</td><td>' . dolibarr_print_date($fac->date_lim_reglement,"%A %d %B %Y");  
       if ($fac->paye == 0 && $fac->date_lim_reglement < (time() - $warning_delay)) print img_warning($langs->trans("Late"));  
       print "</td></tr>";  
   
       // Conditions et modes de réglement  
       print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">'. $fac->cond_reglement . '</td>';  
       print '<td width="25%">'.$langs->trans("PaymentMode").'</td><td width="25%">'. $fac->mode_reglement . '</td></tr>';  
   
       print '<tr>';  
       if ($conf->projet->enabled)  
         {  
           $langs->load("projects");  
           print '<td height=\"10\">'.$langs->trans("Project").'</td><td colspan="3">';  
           if ($fac->projetid > 0)  
             {  
               $projet = New Project($db);  
               $projet->fetch($fac->projetid);  
               print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$fac->projetid.'">'.$projet->title.'</a>';  
             }  
           else  
             {  
               print '&nbsp;';  
             }  
           print "&nbsp;</td>";  
         }  
       else  
         {  
           print '<td height=\"10\">&nbsp;</td><td colspan="3">';  
           print "&nbsp;</td>";  
         }  
       print '<td colspan="2" rowspan="4" valign="top" width="50%">';  
         
       /*  
        * Documents  
        *  
        */        
           $facref = sanitize_string($fac->ref);  
           $file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";  
       $filedetail = $conf->facture->dir_output . "/" . $facref . "/" . $facref . "-detail.pdf";  
       $relativepath = "${facref}/${facref}.pdf";  
       $relativepathdetail = "${facref}/${facref}-detail.pdf";  
       $relativepathimage = "${facref}/${facref}.pdf.png";  
         
       $fileimage = $file.".png";  
           
           $var=true;  
             
       // Si fichier PDF existe  
       if (file_exists($file))  
         {  
         $encfile = urlencode($file);  
         print_titre($langs->trans("Documents"));  
109          print '<table class="border" width="100%">';          print '<table class="border" width="100%">';
110                    
111          print "<tr $bc[$var]><td>".$langs->trans("Bill")." PDF</td>";          // Societe
112                    print '<tr><td>'.$langs->trans("Company").'</td>';
113          print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepath).'">'.$fac->ref.'.pdf</a></td>';          print '<td colspan="5">';
114          print '<td align="right">'.filesize($file). ' bytes</td>';          print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
         print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';  
115          print '</tr>';          print '</tr>';
116            
117          // Si fichier detail PDF existe          // Dates
118          if (file_exists($filedetail)) // facture détaillée supplémentaire          print '<tr><td>'.$langs->trans("Date").'</td>';
119            print '<td colspan="3">'.dolibarr_print_date($fac->date,"%A %d %B %Y").'</td>';
120            print '<td>'.$langs->trans("DateClosing").'</td><td>' . dolibarr_print_date($fac->date_lim_reglement,"%A %d %B %Y");
121            if ($fac->paye == 0 && $fac->date_lim_reglement < (time() - $warning_delay)) print img_warning($langs->trans("Late"));
122            print "</td></tr>";
123    
124            // Conditions et modes de réglement
125            print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">';
126            $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->cond_reglement_id,"none");
127            print '</td>';
128            print '<td width="25%">'.$langs->trans("PaymentMode").'</td><td width="25%">';
129            $html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->mode_reglement_id,"none");
130            print '</td></tr>';
131    
132            print '<tr>';
133            if ($conf->projet->enabled)
134          {          {
135              print "<tr $bc[$var]><td>Facture détaillée</td>";              $langs->load("projects");
136                            print '<td>'.$langs->trans("Project").'</td><td colspan="3">';
137              print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$fac->ref.'-detail.pdf</a></td>';                        if ($fac->projetid > 0)
138              print '<td align="right">'.filesize($filedetail). ' bytes</td>';              {
139              print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedetail)).'</td>';                  $projet = New Project($db);
140              print '</tr>';                  $projet->fetch($fac->projetid);
141                    print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$fac->projetid.'">'.$projet->title.'</a>';
142                }
143                else
144                {
145                    print '&nbsp;';
146                }
147                print "&nbsp;</td>";
148          }          }
149                    else
150          print "</table>\n";          {
151                        print '<td>&nbsp;</td><td colspan="3">';
152          // Conversion du PDF en image png si fichier png non existant              print "&nbsp;</td>";
153          if (!file_exists($fileimage))          }
154            print '<td colspan="2" rowspan="4" valign="top" width="50%">';
155    
156            /*
157            * Documents
158            *
159            */
160            $facref = sanitize_string($fac->ref);
161            $file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
162            $filedetail = $conf->facture->dir_output . "/" . $facref . "/" . $facref . "-detail.pdf";
163            $relativepath = "${facref}/${facref}.pdf";
164            $relativepathdetail = "${facref}/${facref}-detail.pdf";
165            $relativepathimage = "${facref}/${facref}.pdf.png";
166    
167            $fileimage = $file.".png";
168    
169            $var=true;
170    
171            // Si fichier PDF existe
172            if (file_exists($file))
173          {          {
174              if (function_exists(imagick_readimage)) {              $encfile = urlencode($file);
175                  $handle = imagick_readimage( $file ) ;              print_titre($langs->trans("Documents"));
176                  if ( imagick_iserror( $handle ) )              print '<table class="border" width="100%">';
177                  {  
178                    $reason      = imagick_failedreason( $handle ) ;              print "<tr $bc[$var]><td>".$langs->trans("Bill")." PDF</td>";
179                    $description = imagick_faileddescription( $handle ) ;  
180                                  print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepath).'">'.$fac->ref.'.pdf</a></td>';
181                    print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";              print '<td align="right">'.filesize($file). ' bytes</td>';
182                print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
183                print '</tr>';
184    
185                // Si fichier detail PDF existe
186                if (file_exists($filedetail)) // facture détaillée supplémentaire
187                {
188                    print "<tr $bc[$var]><td>Facture détaillée</td>";
189    
190                    print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$fac->ref.'-detail.pdf</a></td>';
191                    print '<td align="right">'.filesize($filedetail). ' bytes</td>';
192                    print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedetail)).'</td>';
193                    print '</tr>';
194                }
195    
196                print "</table>\n";
197    
198                // Conversion du PDF en image png si fichier png non existant
199                if (!file_exists($fileimage))
200                {
201                    if (function_exists(imagick_readimage)) {
202                        $handle = imagick_readimage( $file ) ;
203                        if ( imagick_iserror( $handle ) )
204                        {
205                            $reason      = imagick_failedreason( $handle ) ;
206                            $description = imagick_faileddescription( $handle ) ;
207    
208                            print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
209                        }
210    
211                        imagick_convert( $handle, "PNG" ) ;
212    
213                        if ( imagick_iserror( $handle ) )
214                        {
215                            $reason      = imagick_failedreason( $handle ) ;
216                            $description = imagick_faileddescription( $handle ) ;
217    
218                            print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
219                        }
220    
221                        imagick_writeimage( $handle, $file .".png");
222                  }                  }
223                                    else {
224                  imagick_convert( $handle, "PNG" ) ;                      $langs->load("other");
225                                        print $langs->trans("ErrorNoImagickReadimage");
                 if ( imagick_iserror( $handle ) )  
                 {  
                   $reason      = imagick_failedreason( $handle ) ;  
                   $description = imagick_faileddescription( $handle ) ;  
                     
                   print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";  
226                  }                  }
                   
                 imagick_writeimage( $handle, $file .".png");  
             }  
             else {  
                 $langs->load("other");  
                 print $langs->trans("ErrorNoImagickReadimage");  
227              }              }
228    
229          }          }
           
         }  
230    
231        /*          /*
232         *          *
233         *          *
234         */          */
235          
236        print "</td></tr>";          print "</td></tr>";
237          
238        print "<tr><td height=\"10\">".$langs->trans("Author")."</td><td colspan=\"3\">$author->fullname</td>";          print "<tr><td>".$langs->trans("Author")."</td><td colspan=\"3\">$author->fullname</td>";
239          
240        print '<tr><td height=\"10\" nowrap>'.$langs->trans("GlobalDiscount").'</td>';          print '<tr><td nowrap>'.$langs->trans("GlobalDiscount").'</td>';
241        print '<td align="right" colspan="2">'.$fac->remise_percent.'</td>';          print '<td align="right" colspan="2">'.$fac->remise_percent.'</td>';
242        print '<td>%</td></tr>';          print '<td>%</td></tr>';
243          
244        print '<tr><td height=\"10\">'.$langs->trans("AmountHT").'</td>';          print '<tr><td>'.$langs->trans("AmountHT").'</td>';
245        print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>';          print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>';
246        print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';          print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
247                    
248        print '</table>';          print '</table>';
249          
250      }      }
251    else      else
252      {      {
253        // Facture non trouvée          // Facture non trouvée
254        print $langs->trans("ErrorBillNotFound",$_GET["facid"]);          print $langs->trans("ErrorBillNotFound",$_GET["facid"]);
255      }      }
256  }    }
257    
258  if (file_exists($fileimage))  if (file_exists($fileimage))
259  {          {        

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26